[英]How to divide screen evenly in 3?
我已經在使用此計算:
size = act.getWindow().getDecorView().getWidth()/3;
int dip = (int)TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_DIP,
size,
r.getDisplayMetrics()
);
但是,我的圖像太大了。 我需要做什么?
一種簡單的方法是在定義XML時分配布局權重:
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="@drawable/example"
weight="1" />
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="@drawable/example"
weight="1" />
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="@drawable/example"
weight="1" />
</LinearLayout>
您也可以使用ScaleType屬性來更改圖像的縮放比例,希望對您有所幫助!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.