Module view

Module view 

Source
Expand description

Base View type and common view operations

§Important Notes on Dimensions and Units

Android uses two different units for View dimensions:

  • dp (density-independent pixels): Default unit, scales with screen density
  • px (pixels): Actual screen pixels

§Critical for TabLayout/ScrollView

When working with HorizontalScrollView or TabLayout:

  1. get_dimensions() returns values in pixels (px)
  2. set_width() and set_height() use dp by default
  3. You must use set_width_px() and set_height_px() to match dimensions!

§Example

// Get dimensions (returns pixels)
let (width_px, height_px) = scroll_view.view().get_dimensions(activity)?;

// WRONG: This uses dp, not px!
// page.view().set_width(activity, width_px)?;  // Width mismatch!

// CORRECT: Use set_width_px to match pixel values
page.view().set_width_px(activity, width_px)?;  // Perfect match!

Structs§

View
Base View structure

Constants§

MATCH_PARENT
Special dimension constants for Android layouts
WRAP_CONTENT