View

Struct View 

Source
pub struct View { /* private fields */ }
Expand description

Base View structure

Implementations§

Source§

impl View

Source

pub fn new(id: i64) -> Self

Create a new View with the given ID

Source

pub fn id(&self) -> i64

Get the view ID

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn set_dimensions( &self, activity: &mut Activity, width: i32, height: i32, ) -> Result<()>

Set view width and height

Source

pub fn set_margin(&self, activity: &mut Activity, margin: i32) -> Result<()>

Set view margin

Source

pub fn set_width_wrap_content(&self, activity: &mut Activity) -> Result<()>

Set view width to WRAP_CONTENT

Source

pub fn set_height_wrap_content(&self, activity: &mut Activity) -> Result<()>

Set view height to WRAP_CONTENT

Source

pub fn set_width_match_parent(&self, activity: &mut Activity) -> Result<()>

Set view width to MATCH_PARENT

Source

pub fn set_height_match_parent(&self, activity: &mut Activity) -> Result<()>

Set view height to MATCH_PARENT

Source

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 activity
  • weight - Layout weight (higher weight = more space)
  • position - Optional position index in the layout
Source

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”
Source

pub fn get_dimensions(&self, activity: &mut Activity) -> Result<(i32, i32)>

Get the dimensions (width, height) of this view in pixels Returns (width, height)

Source

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)?;

Auto Trait Implementations§

§

impl Freeze for View

§

impl RefUnwindSafe for View

§

impl Send for View

§

impl Sync for View

§

impl Unpin for View

§

impl UnwindSafe for View

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V