如何显示控制在Android的各种屏幕分辨率的固定位置?

我有一个屏幕设计象下面

<?xml version="1.0" encoding="utf-8"?>
<TableLayout
   xmlns:android="http://schemas.android.com/apk/res/android"
   android:gravity="center_horizontal"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent"
   android:orientation="vertical"
   android:background="@drawable/img_background_loadbackground">
<TableRow>
<TextView
   android:id="@+id/tv1"
   android:layout_width="fill_parent" 
   android:layout_height="300sp"/>
</TableRow>

<TableRow>
</TableRow>
<ProgressBar 
   android:id="@+id/progressbar" 
   style="?android:attr/progressBarStyleHorizontal" 
   android:layout_width="fill_parent" 
   android:layout_height="wrap_content" />
</TableLayout>

据在HVGA工作(480)的分辨率,进度条显示在屏幕的底部,但是,如果我在其它分辨率(WQVGA432 - 240x432)运行进度显示在屏幕的中间。我不能显示它在一个固定的位置。

我使用下面的清单文件显示,但没有输出

<supports-screens android:smallScreens="true"  
                android:normalScreens="true" 
                android:largeScreens="true"  
                android:anyDensity="true" />

我没有一个解决方案,所以请给我一些想法来解决问题。

有帮助吗?

解决方案

如果你希望你的布局,在不同分辨率的屏幕你应该使用dip为单位来定型他们的工作。例如:

android:layout_marginRight="10dip"

dip表示与设备无关的像素和在布局中使用这些意味着Android将自动缩放布局,这取决于显示设备运行应用程序了。

您可以阅读这些在支持多种屏幕在Android开发人员文档页。该文件还对处理不同显示一些其他的选择,但我想用dip可能是最容易的。

其他提示

这要看你如何定义你的布局:发布您的布局XML将帮助这里

我猜想如果在中间你有这样的:

android:layout_gravity="center"

但是,是的,发布您的XML会有点帮助!

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top