【发布时间】:2014-03-05 07:04:40
【问题描述】:
我正在编写一个在 720p 屏幕上运行良好的应用程序。我想让这个应用程序在不同的屏幕尺寸上运行。我看了这篇文章:http://developer.android.com/guide/practices/screens_support.html
但我很困惑。我为不同的布局(layout-normal、layout-large、layout-xlarge)创建了 3 个文件夹,并在每个文件夹中放置了一个不同的 XML 文件。但是有些屏幕布局正常,我的应用在其中一些上看起来不错,而在另一些上看起来很糟糕。例如,这些尺寸是正常布局:(4.7" WXGA, 4" WVGA, 3.7" WVGA, ...) 但我的应用在 4" 和 3.7" 上看起来不错,而在其他类型上看起来很糟糕。
我在layout-normal文件夹中的activity-main.xml是:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/backasli"
android:orientation="vertical" >
<TableLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingBottom="100dp"
android:paddingTop="140dp"
android:stretchColumns="3" >
<TableRow
android:id="@+id/tableRow6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center" >
<TextView
android:id="@+id/txt1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="pray :"
android:textColor="#031a7b"
android:textSize="15sp" />
</TableRow>
<TableRow
android:id="@+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center" >
<TextView
android:id="@+id/namaztxt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:textColor="#031a7b"
android:textSize="20sp" />
</TableRow>
<TableRow android:gravity="center" >
<Button
android:id="@+id/buttonchange"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:background="@drawable/ubtn"
android:text="change"
android:textColor="#ffffff"
android:textSize="20sp" />
</TableRow>
</TableLayout>
</LinearLayout>
【问题讨论】:
-
我认为 android:paddingBottom="100dp" android:paddingTop="140dp" 这会给您的设备对齐带来问题?从某种意义上说它如何显示不好??
-
@Lokesh 。确切地!!!这些垫子有问题
-
然后根据你所有布局中的屏幕更改填充..
-
@Lokesh,许多屏幕尺寸都是正常布局的,这些代码对其中一些有好处。我应该为每个屏幕添加布局吗?比如 layout-normal-3.7" ,layout-normal-4" 等等?
-
只需要一个布局文件。不再。聪明地编码。至多,使用样式来改变真正大屏幕的权重。
标签: android android-layout layout multiscreen