我见过应用程序,当在任何设备上运行时,它对设备的scree感觉非常完美。我该怎么做:下面是我的代码。对于一些较小的设备,布局非常适合屏幕。但是对于更高的屏幕分辨率,它不适合屏幕。我如何使它适合屏幕,是否有任何工具可用于实现这一目标?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_gravity="center_horizontal"
android:background="@drawable/bgmenu" >
<ScrollView
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:background="@drawable/bgmenu" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="561dp"
android:layout_gravity="center_horizontal"
android:orientation="vertical" >
<View
android:layout_width="fill_parent"
android:layout_height="10dp" />
<View
android:layout_width="fill_parent"
android:layout_height="30dp" />
<View
android:layout_width="fill_parent"
android:layout_height="2dp"
android:background="#000" />
<Button
android:id="@+id/btnHausa"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="onClick"
android:text="@string/hausa"
android:textColor="#FFF"
android:textStyle="bold" />
<View
android:layout_width="fill_parent"
android:layout_height="2dp"
android:background="#000" />
<View
android:layout_width="fill_parent"
android:layout_height="15dp" />
<View
android:layout_width="fill_parent"
android:layout_height="2dp"
android:background="#000" />
<Button
android:id="@+id/btnYoruba"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="onClick"
android:text="@string/yoruba"
android:textColor="#FFF"
android:textStyle="bold" />
<View
android:layout_width="fill_parent"
android:layout_height="2dp"
android:background="#000" />
<View
android:layout_width="fill_parent"
android:layout_height="15dp" />
<View
android:layout_width="fill_parent"
android:layout_height="2dp"
android:background="#000" />
<Button
android:id="@+id/btnIgbo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="onClick"
android:text="@string/igbo"
android:textColor="#FFF"
android:textStyle="bold" />
<View
android:layout_width="fill_parent"
android:layout_height="2dp"
android:background="#000" />
<View
android:layout_width="fill_parent"
android:layout_height="15dp" />
<View
android:layout_width="fill_parent"
android:layout_height="2dp"
android:background="#000" />
<Button
android:id="@+id/btnPidginEnglish"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="onClick"
android:text="@string/PidginEnglish"
android:textColor="#FFF"
android:textStyle="bold" />
<View
android:layout_width="fill_parent"
android:layout_height="2dp"
android:background="#000" />
<View
android:layout_width="fill_parent"
android:layout_height="15dp" />
<View
android:layout_width="fill_parent"
android:layout_height="2dp"
android:background="#000" />
<Button
android:id="@+id/btnEnglish"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="onClick"
android:text="@string/english"
android:textColor="#FFF"
android:textStyle="bold" />
<View
android:layout_width="fill_parent"
android:layout_height="2dp"
android:background="#000" />
</LinearLayout>
</ScrollView>
</LinearLayout>
答案 0 :(得分:2)
我建议您阅读此文档http://developer.android.com/guide/practices/screens_support.html
或本文“为多个屏幕设计”
http://developer.android.com/training/multiscreen/index.html
答案 1 :(得分:0)
您必须在res内使用不同的布局文件夹以适应多个屏幕 请仔细阅读http://developer.android.com/guide/practices/screens_support.html
答案 2 :(得分:0)
您应该使用android:layout_height="561dp"
或android:layout_height="wrap_content"
,而不是在android:layout_height="match_parent"
等属性中使用硬代码值,因为这可以被视为良好做法。另一方面,您可以创建drawables标准尺寸由谷歌在设计指南中提供,将drawables放在android项目的 res 中的相应 drawable 文件夹中。
答案 3 :(得分:0)
诀窍在于androidmanifest.xml 将以下内容添加到应用程序根目录的清单中:
<activity
android:name=".Foo"
android:label="@string/foo"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen">