【发布时间】:2013-04-24 19:37:23
【问题描述】:
我想按百分比设置边距。我在线性布局中有 4 个图像视图,并希望设置默认的左、右、上、下边距,使每个屏幕尺寸保持相同的百分比。
有可能吗?
这是我想要的演示..
这是我尝试过但不起作用的方法
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:weightSum="10" >
<Thumbnail
android:id="@+id/thumb1"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="4" />
<Thumbnail
android:id="@+id/thumb2"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="4" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:weightSum="10" >
<Thumbnail
android:id="@+id/thumb3"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="4" >
</Thumbnail>
<Thumbnail
android:id="@+id/thumb4"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="4" />
</LinearLayout>
</LinearLayout>
感谢您的帮助
【问题讨论】:
标签: android android-linearlayout