【发布时间】:2014-12-02 20:11:29
【问题描述】:
我是一个最业余的应用程序开发人员,我觉得我对 Android 基础知识掌握得很好,但我最擅长的事情是应用程序设计。我了解如何针对不同的屏幕尺寸和密度进行开发。但我最挣扎的是,每个正常尺寸和其他尺寸都涵盖了它们各自类别中的这么大范围的尺寸。我一直在寻找和寻找,但无法找到解决方案。
我遇到的主要问题是在使用 Eclipse 进行设计时,我使用 nexus one 进行设计,当我切换到像 3.2 HVGA 甚至是正常的 nexus 星系这样的较小屏幕时,该设计看起来非常适合我想要的东西大小的图像,我的图像的位置已经移动。因此,在其他一些正常的屏幕尺寸上,看起来非常适合 nexus 的东西看起来很糟糕。
可以做些什么来确保一个图像是否直接紧挨另一个图像在不同的屏幕上保持这种方式。我将举一个我正在做的当前设计的例子,我希望有人能解释我做错了什么/如何改进。
Nexus One 设计:
3.2 HVGA:
the xml generated:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/RelativeLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:columnCount="4"
android:orientation="vertical" >
<Button
android:id="@+id/Button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:background="@drawable/i1"
android:text="Button" />
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:background="@drawable/i2" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/Button1"
android:layout_alignTop="@+id/Button1"
android:layout_marginLeft="106dp"
android:layout_marginTop="160dp"
android:background="@drawable/i3" />
<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/button2"
android:layout_alignBottom="@+id/button2"
android:layout_alignRight="@+id/Button1"
android:layout_marginRight="112dp"
android:background="@drawable/i4" />
<Button
android:id="@+id/button4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/button3"
android:layout_alignLeft="@+id/button3"
android:background="@drawable/i5" />
</RelativeLayout>
【问题讨论】:
标签: android resize android-relativelayout dpi screen-size