我正在开发一款Android 2.2.2应用程序,它将支持多种屏幕尺寸,并且所有屏幕都将是人像。我不会支持风景。相同的布局在三星Galaxy Tab上看起来不同
我在HTC Desire和Samsung Galaxy Tab 7.7上测试了以下布局。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mainLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/no_conectado"
android:orientation="vertical" >
<TextView
android:id="@+id/labelSelGateName"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:layout_marginTop="80dp" />
<TextView
android:id="@+id/labelSelOpened"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal" />
<ProgressBar
android:id="@+id/indicatorActivityView"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_marginTop="22dp"
android:layout_gravity="center_horizontal" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="110dp"
android:layout_marginTop="60dp"
android:orientation="horizontal" >
<ImageButton
android:id="@+id/btnMyGates"
android:layout_width="50dp"
android:layout_height="110dp"
android:layout_marginLeft="20dp"
android:layout_weight=".33"
android:background="@null"
android:contentDescription="@string/layout_empty"
android:onClick="onGateClick" />
<LinearLayout
android:layout_width="90dp"
android:layout_height="110dp"
android:layout_weight=".33"
android:orientation="vertical" >
<ImageButton
android:id="@+id/btnOpen"
android:layout_width="90dp"
android:layout_height="55dp"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="@null"
android:contentDescription="@string/layout_empty"
android:onClick="onOpenDoorClick" />
<ImageButton
android:id="@+id/btnClose"
android:layout_width="90dp"
android:layout_height="50dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="@null"
android:contentDescription="@string/layout_empty"
android:onClick="onCloseDoorClick" />
</LinearLayout>
<ImageButton
android:id="@+id/btnOptions"
android:layout_width="50dp"
android:layout_height="110dp"
android:layout_marginRight="20dp"
android:layout_weight=".33"
android:background="@null"
android:contentDescription="@string/layout_empty"
android:onClick="onOptionClick" />
</LinearLayout>
<ImageButton
android:id="@+id/btnFaqs"
android:layout_width="110dp"
android:layout_height="60dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="10dp"
android:background="@null"
android:contentDescription="@string/layout_empty"
android:onClick="onFAQClick" />
<ImageButton
android:id="@+id/btnInfo"
android:layout_width="110dp"
android:layout_height="60dp"
android:layout_gravity="right"
android:layout_marginTop="20dp"
android:background="@null"
android:contentDescription="@string/layout_empty"
android:onClick="onInfoClick" />
</LinearLayout>
我有ldpi,mdpi,hdpi和x-hdpi的图片。
背景图像看起来不错,但是所有小工具(TextView
,ProgressBar
,ImageButton
等)在Samsung Galaxy Tab上测试时都不在正确的位置。
我在Eclipse上使用'Nexus One'作为模型设计了这个布局。
Here有人推荐我对每种屏幕尺寸和密度只使用一种布局,但它不起作用。我使用的是dp
单元和fill_parent
等,但它在Galaxy Tab上不同。
我需要x-large
屏幕尺寸的布局吗?
很糟糕的布局设计。 – 2012-07-24 07:48:31
@PadmaKumar你推荐我什么? – VansFannel 2012-07-24 07:53:54
使用相对布局而不使用硬编码。 – 2012-07-24 08:00:20