【发布时间】:2011-07-17 09:55:41
【问题描述】:
我想进行以下布局,请参见下图,其中 EditText 视图的位置保持正确位置 w.r.t。箭头。
下面的布局是我使用页边距使用 RelativeLayout 制作的,但是当有人将此应用程序安装在 540x960 分辨率的手机上(如 HTC 感觉)时,这将不起作用。
提前感谢您的帮助!
【问题讨论】:
标签: android layout screen-resolution uniform
我想进行以下布局,请参见下图,其中 EditText 视图的位置保持正确位置 w.r.t。箭头。
下面的布局是我使用页边距使用 RelativeLayout 制作的,但是当有人将此应用程序安装在 540x960 分辨率的手机上(如 HTC 感觉)时,这将不起作用。
提前感谢您的帮助!
【问题讨论】:
标签: android layout screen-resolution uniform
使用 LinearLayout 和 RelativeLayout 的组合。使用 LinearLayout,您可以在屏幕上创建与所有设备完全相同的空间。让您的顶级容器成为 LinearLayout。例如,要在您引用的图像中创建第二行,请执行以下操作:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1">
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true">
</TextView>
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1">
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true">
</TextView>
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1">
</RelativeLayout>
</LinearLayout>
【讨论】: