我的应用程序包含屏幕上带有一些文本的关闭按钮。它真的很简单,这就是它所需要的。
但是当我在不同的虚拟手机上测试我的应用程序时,它看起来会有所不同。现在,由于我不使用图像,因此我假设只要我的图像位于 drawable 文件夹中,并且并非所有图像都位于不同的 drawable- * * 文件夹中,它们就不会成为问题。
但是我如何编码 XML 以适应所有智能手机屏幕。
XML:
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="@+id/textView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:padding="@dimen/padding_medium"
android:text="@string/welsh_libs"
android:textColor="#FF0066"
android:textSize="30dip"
android:textStyle="bold"
tools:context=".WelshLibraries" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
<Button
android:id="@+id/button2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginLeft="18dp"
android:background="#6088A1"
android:textColor="#FFFFFF"
android:text="@string/news" />
<Button
android:id="@+id/button3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginLeft="18dp"
android:background="#50C0E9"
android:textColor="#000000"
android:text="@string/find_lib" />
<Button
android:id="@+id/button4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginLeft="18dp"
android:background="#6088A1"
android:textColor="#FFFFFF"
android:text="@string/free_res" />
<Button
android:id="@+id/button5"
android:layout_width="285dp"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginLeft="18dp"
android:background="#50C0E9"
android:text="@string/ask_lib"
android:textColor="#000000" />
<Button
android:id="@+id/button6"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginLeft="18dp"
android:background="#6088A1"
android:text="@string/find_book"
android:textColor="#FFFFFF" />
<Button
android:id="@+id/button7"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginLeft="18dp"
android:background="#50C0E9"
android:text="@string/register"
android:textColor="#000000" />
<Button
android:id="@+id/button8"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginLeft="18dp"
android:background="#6088A1"
android:text="@string/login"
android:textColor="#FFFFFF" />
</LinearLayout>
<ImageView
android:id="@+id/image1"
android:layout_width="190dp"
android:layout_height="0dip"
android:layout_marginBottom="5dp"
android:layout_marginLeft="70dp"
android:layout_weight="1"
android:contentDescription="@string/desc"
android:src="@drawable/waglogo"
android:visibility="visible" />
我使用 dp 作为测量单位,但我知道它是唯一可以使用的单位,所以我知道它不像设计一个可以使用 pxs、ems 和 %s 的网站。
人们可以提供的任何帮助或链接将不胜感激。谢谢,丹
PS 如果我想在应用程序加载时在 8 个下方添加更多按钮,我也在寻找一种向下滚动的方法。有任何想法吗?