好吧! 我现在正在开发Android应用程序,但我想知道如何将所有布局放到多个设备屏幕上。Android多屏幕 - 将UI用于用户界面
*我做了多个屏幕文件夹。
RES /布局小/ main.xml中
RES /布局正常/ main.xml中
RES /布局大/ main.xml中
RES /布局XLARGE /主.xml
*下面是我的代码示例。
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:layout_width="120dp"
android:layout_height="70dp"
android:text="@sting/button1" >
<Button
android:layout_width="120dp"
android:layout_height="70dp"
android:text="@sting/button2" >
<Button
android:layout_width="120dp"
android:layout_height="70dp"
android:text="@sting/button3" >
<Button
android:layout_width="120dp"
android:layout_height="70dp"
android:text="@sting/button3" >
</LinearLayout>
</LinearLayout>
正如你所看到的,我对每个按钮都使用了120dp。 当我在虚拟设备机器中运行时,屏幕很合适。 (因为我在虚拟设备机器上使用了480dp宽度的屏幕。) 但是,当我在真实的手机设备(我的:三星Galaxy Note 1(韩国版),我父亲的:三星Galaxy S2(韩国版)和我妈妈的:三星Galaxy S(加拿大版)),尽管我创建了不同大小的屏幕文件夹,但我可以看到按钮的(宽度)距设备的屏幕布局太远。 谁能告诉我如何适应所有的设备屏幕? 在这种情况下,我仍然可以使用dp吗? (请给我一个例子!)
你应该使用'wrap_content'或'match_parent' – tyczj
@tyczj谢谢您的答复。我确实使用了wrap_content,它看起来很糟糕。我不喜欢普通的按钮风格。 – user3653228