Android的定位问题 [英] Android positioning problems

查看:148
本文介绍了Android的定位问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我的问题是简单 - 我想用XML布局,以precisely控制多个设备上的小部件的定位。要做到这一点,我仔细阅读了谷歌文档上支持多个设备。据一部分,WVGA854和HVGA都被认为是普​​通屏幕大小。所以理论上,在WVGA854定位一个部件应该看起来一样为HVGA。然而,所得的截图,否则显示。

So my problem is simple- I want to use XML layouts to precisely control the positioning of widgets on multiple devices. To do this, I thoroughly read the google docs on supporting multiple devices. According to this part, the WVGA854 and HVGA are both considered "Normal screen" size. So theoretically, positioning a widget on WVGA854 should look the same as with HVGA. However, the resultant screenshot shows otherwise.

小部件出现相对较高置于WVGA854皮肤。该XML code如下图所示,并且布局正常/文件夹下放置:

The widget appears relatively higher placed on the WVGA854 skin. The XML code is shown below, and was placed under the layout-normal/ folder:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <ImageButton
        android:id="@+id/button1"
        android:src="@drawable/icon_unlock"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="300dp"
        android:text="Button" />

</RelativeLayout>

我构建的可绘制在适当的比例(3:4:6:8的的推荐)。那么,为什么这种定位不匹配的发生呢?我开始觉得用XML来定位的东西是相当徒劳的。我的应用程序需要的小部件定位非常准确所以即使这个轻微的不匹配是一个问题。任何帮助我怎样才能解决这个问题?

The drawables I constructed are in the proper ratios (3:4:6:8 as recommended). So why does this positioning mismatch happen? I beginning to think that using XML to position things is quite fruitless. My app requires very accurate positioning of widgets so even this slight mismatch is a problem. Any help how I can remedy this?

编辑:
我想是用于向被放置在以这样的方式余量的由上到从底部边缘的比率是完全一样的跨设备的部件。从截图中可以看到,这个比例是不是WQVGA854和HVGA一样的。

What I want is for the widget to be placed in a manner such that the ratio of margin from top to the margin from bottom is exactly the same across devices. From the screenshot, you can see that this ratio is not the same for WQVGA854 and HVGA.

推荐答案

普通屏幕尺寸并不意味着屏幕具有完全相同的号码浸。你需要把它作为包含了许多不同的屏幕尺寸这在物理尺寸所有类似的水桶。

"Normal Screen" size does not mean that screens have the exact same number of dip. You need to think of it as a bucket which contains a number of different screen sizes which are all similar in physical size.

所以使用固定大小的边距和补不(容易)要达到你需要的效果。所以,请澄清你的问题,并给什么你到底想达到一个例子。

so using fixed size margins and paddings is not (easily) going to achieve the effect you need. So please clarify your question and give an example of what you exactly want to achieve.

这篇关于Android的定位问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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