【发布时间】:2014-02-04 20:57:26
【问题描述】:
我正在尝试创建一个布局,其中图像位于左侧 20% 的屏幕尺寸、右侧 20% 的屏幕尺寸和顶部 30% 的屏幕尺寸。我可以将图像定位为距侧面距离的 20%,但不知道如何同时结合顶部和侧面的百分比。现在我使用 android:layout_marginTop 从顶部边缘跳转。我想使用一些可以在任何屏幕分辨率上从顶部腾出 30% 可用屏幕空间的东西。请看图1。非常感谢您的帮助。
XML 代码:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:weightSum="100" >
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="20" />
<ImageView
android:id="@+id/imageView4"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:layout_marginTop="100dp"
android:layout_weight="60"
android:src="@drawable/logo_line" />
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="20" />
</LinearLayout>
【问题讨论】:
标签: android android-layout screen-resolution