版面设计 3.2寸屏android

layout desing 3.2 inch screen android

当我创建布局时,我添加了一个图像视图,然后添加了两个按钮。 在 5 英寸屏幕上看起来还不错,但在 3.2 英寸屏幕上底部的按钮显示不正确。一半按钮超出屏幕。

这是我的代码:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
    android:layout_marginLeft="10.0dip"
    android:layout_marginTop="20.0dip"
    android:layout_marginRight="10.0dip"
    style="@style/TextPrincipal"
    android:text="@string/ferits_activity"/>
<View android:id="@+id/separator"
    android:background="#8a9597"
    android:layout_width = "fill_parent"
    android:layout_height="2dip"
    android:layout_centerVertical ="true"
    android:layout_alignParentTop="true"/>
<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center_horizontal"
    android:orientation="horizontal"
    >
    <ImageView
        android:layout_width="50dip"
        android:layout_height="30dip"
        android:src="@drawable/esquerra"
        android:layout_weight="1"
        android:layout_gravity="center_vertical"
        />
    <ImageView
        android:id="@+id/FeritsImatge"
        android:layout_width="300dip"
        android:layout_height="240dip"
        android:contentDescription="@string/ferits_activity"
        android:layout_marginRight="20dip"
        android:src="@drawable/esta_ferida"
        android:layout_weight="1"
        android:layout_gravity="center_vertical"
        />
</LinearLayout>
<RelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_marginLeft="40.0dip"
    android:layout_marginRight="40.0dip"
    android:layout_alignParentRight="true"
    android:layout_alignParentEnd="true"
    style="@style/AppTheme">
    <Button android:id="@+id/BotoSiFerits"
        android:background="#ffabd128"
        android:clickable="true"
        android:layout_width="fill_parent"
        android:layout_height="50.0dip"
        android:layout_marginTop="10.0dip"
        android:text="@string/resposta_si"
        android:textColor="@color/blanc"
        style="@style/AppTheme"
        android:onClick="passarMoure"/>
    <Button android:id="@+id/BotoNoFerits"
        android:background="#ffabd128"
        android:clickable="true"
        android:layout_width="fill_parent"
        android:layout_height="50.0dip"
        android:layout_marginTop="10.0dip"
        android:text="@string/resposta_no"
        android:layout_below="@id/BotoSiFerits"
        android:textColor="@color/blanc"
        style="@style/AppTheme"
        android:onClick="passarEsperar" />
</RelativeLayout>
</LinearLayout>

当内容太多无法显示在屏幕上时,您有两个常规选项:

  1. 针对较小的屏幕调整内容的大小或布局,以便所有内容都能适合屏幕
  2. 使用 ScrollView 以便用户在屏幕较小的情况下可以滚动您的内容。

我建议使用选项 2,因为它将在设备之间提供更一致的体验。

您的布局最终应如下所示:

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <!-- Your existing LinearLayout with the height set to wrap_content -->

</ScrollView>