Android的图像定位支持多种屏幕分辨率
问题描述:
我已经有相同的问题很长一段时间了,这基本上是标题说的。我画了一些图片来想象我想要达到的目标。Android的图像定位支持多种屏幕分辨率
Picture of man on ground 所以在第一个pickture中,我们有一个人(玩家)站在背景图像的地面上。在1024x728设备中,此播放器位于屏幕高度周围的某处 - 120px。我wan't支持多种屏幕分辨率,但是当我在更大的屏幕上运行应用程序,这种情况当然是:
picture of man not on ground 背景的高度较大,为此地面是从底部futher路程, -120px是不够的。
(在应用程序中的照片;照片绘制的帆布作为位图)
所以我的问题是,我怎么做到让这个人总是对地面的位置?什么是最佳做法?你能告诉我一些例子吗?
非常感谢。
答
有两种aproaches:
1)使用RelativeLayout
孩子这种布局可以在关系中指定的其他子女
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingLeft="16dp"
android:paddingRight="16dp" >
<EditText
android:id="@+id/name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="@+id/name"> <<<< look at this
</RelativeLayout>
2)使用刚刚添加比例支持库。您可以在屏幕上指定%位置。阅读this为它
请张贴您的代码,因为它是不可能猜测你做错了什么或可以改进什么。 – Sebastian