如何显示在了Android中不同的屏幕分辨率固定位置的控制? [英] How do I show controls at a fixed position for various screen resolutions in Android?

查看:344
本文介绍了如何显示在了Android中不同的屏幕分辨率固定位置的控制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

How do I show controls at a fixed position for various screen resolutions in Android?

我有一个屏幕设计像下面

I have a screen design like below

<?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(320×480)分辨率,进度条出现在屏幕的底部,但如果我在其他分辨率(WQVGA432 - 240x432)运行进度条出现在屏幕的中间。我不能显示在一个固定的位置。

It is working in HVGA(320x480) resolution, the progressbar appears at the bottom of the screen, but if I run in other resolution (WQVGA432 - 240x432) the progressbar appears in the middle of the screen. I am not able to show it in a fixed position.

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

I am using the manifest file show below but no output

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

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

I don't have a solution so please give me some idea to resolve the issue.

推荐答案

如果你希望你的布局,在不同分辨率的屏幕你应该使用浸会上浆它们作为工作单元。例如:

If you want your layouts to work on different resolution screens your should be sizing them using dip as the unit. For example:

android:layout_marginRight="10dip"

表示与设备无关的像素,并使用这些在你的布局意味着Android将自动调整你的布局,这取决于显示设备上运行的应用程序。

dip stands for Device Independent Pixel and using these in your layout means that Android will automatically scale your layout depending on which display the device running your application has.

您可以在支持多种阅读这些屏幕的在Android开发者文档页面。该文件还对处理不同的显示一些其他的选择,但我认为使用可能是最简单的。

You can read about these in the Supporting Multiple Screens page in the Android Developer Documentation. This document also has some other options for handling different displays but I think using dip is probably the easiest.

这篇关于如何显示在了Android中不同的屏幕分辨率固定位置的控制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆