pub struct View { /* private fields */ }Expand description
Base View structure
Implementations§
Source§impl View
impl View
Sourcepub fn set_width(&self, activity: &mut Activity, width: i32) -> Result<()>
pub fn set_width(&self, activity: &mut Activity, width: i32) -> Result<()>
Set view width in dp (density-independent pixels)
Note: If you need to match dimensions from get_dimensions(),
use set_width_px() instead, as get_dimensions() returns pixels.
Sourcepub fn set_width_px(&self, activity: &mut Activity, width: i32) -> Result<()>
pub fn set_width_px(&self, activity: &mut Activity, width: i32) -> Result<()>
Set view width in pixels
Use this when matching dimensions from get_dimensions()
which returns pixel values, not dp values.
Sourcepub fn set_height(&self, activity: &mut Activity, height: i32) -> Result<()>
pub fn set_height(&self, activity: &mut Activity, height: i32) -> Result<()>
Set view height in dp (density-independent pixels)
Note: If you need to match dimensions from get_dimensions(),
use set_height_px() instead, as get_dimensions() returns pixels.
Sourcepub fn set_height_px(&self, activity: &mut Activity, height: i32) -> Result<()>
pub fn set_height_px(&self, activity: &mut Activity, height: i32) -> Result<()>
Set view height in pixels
Use this when matching dimensions from get_dimensions()
which returns pixel values, not dp values.
Sourcepub fn set_dimensions(
&self,
activity: &mut Activity,
width: i32,
height: i32,
) -> Result<()>
pub fn set_dimensions( &self, activity: &mut Activity, width: i32, height: i32, ) -> Result<()>
Set view width and height
Sourcepub fn set_width_wrap_content(&self, activity: &mut Activity) -> Result<()>
pub fn set_width_wrap_content(&self, activity: &mut Activity) -> Result<()>
Set view width to WRAP_CONTENT
Sourcepub fn set_height_wrap_content(&self, activity: &mut Activity) -> Result<()>
pub fn set_height_wrap_content(&self, activity: &mut Activity) -> Result<()>
Set view height to WRAP_CONTENT
Sourcepub fn set_width_match_parent(&self, activity: &mut Activity) -> Result<()>
pub fn set_width_match_parent(&self, activity: &mut Activity) -> Result<()>
Set view width to MATCH_PARENT
Sourcepub fn set_height_match_parent(&self, activity: &mut Activity) -> Result<()>
pub fn set_height_match_parent(&self, activity: &mut Activity) -> Result<()>
Set view height to MATCH_PARENT
Sourcepub fn set_linear_layout_params(
&self,
activity: &mut Activity,
weight: i32,
position: Option<i32>,
) -> Result<()>
pub fn set_linear_layout_params( &self, activity: &mut Activity, weight: i32, position: Option<i32>, ) -> Result<()>
Set LinearLayout parameters for this view
§Arguments
activity- The activityweight- Layout weight (higher weight = more space)position- Optional position index in the layout
Sourcepub fn set_grid_layout_params(
&self,
activity: &mut Activity,
row: i32,
col: i32,
row_size: i32,
col_size: i32,
alignment_row: &str,
alignment_col: &str,
) -> Result<()>
pub fn set_grid_layout_params( &self, activity: &mut Activity, row: i32, col: i32, row_size: i32, col_size: i32, alignment_row: &str, alignment_col: &str, ) -> Result<()>
Set GridLayout parameters for this view
§Arguments
row- Row index (0-based)col- Column index (0-based)row_size- Number of rows this view spans (default 1)col_size- Number of columns this view spans (default 1)alignment_row- Vertical alignment: “top”, “bottom”, “center”, “baseline”, “fill”alignment_col- Horizontal alignment: “left”, “right”, “center”, “fill”
Sourcepub fn get_dimensions(&self, activity: &mut Activity) -> Result<(i32, i32)>
pub fn get_dimensions(&self, activity: &mut Activity) -> Result<(i32, i32)>
Get the dimensions (width, height) of this view in pixels Returns (width, height)
Sourcepub fn set_background_color(
&self,
activity: &mut Activity,
color: i32,
) -> Result<()>
pub fn set_background_color( &self, activity: &mut Activity, color: i32, ) -> Result<()>
Set the background color of this view
Color format: 0xAARRGGBB (alpha, red, green, blue in hexadecimal)
§Examples
// Solid red
view.set_background_color(activity, 0xFFFF0000u32 as i32)?;
// Semi-transparent blue
view.set_background_color(activity, 0x800000FFu32 as i32)?;
// White
view.set_background_color(activity, 0xFFFFFFFFu32 as i32)?;