需要输入如何改善小屏幕布局的方法

我有一个如下所示的布局,如下所示。 我的问题是,在小屏幕上,视图底部的按钮被推出了用户的视图。我认为我可以通过在ScrollView中包装整个布局来轻松解决这个问题,但我已经了解到这不是一个可行的解决方案,因为我的布局中有一个ListView。 那么,有关如何更改此布局的任何建议?我的主要问题是我有一个连接到ListView的适配器,我不确定我是否可以重做布局并使用适配器。想什么? 问候 丹尼尔 顺便说一句,这是我的布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" 
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    style="@style/defaultBackground" 
    >
    <LinearLayout 
        android:layout_height="wrap_content" 
        android:layout_width="fill_parent" 
        android:orientation="horizontal"
        android:paddingBottom="10dip"
        >
        <TextView 
            android:id="@+id/roundInfo" 
            android:layout_width="wrap_content" 
            android:layout_height="20dip" android:textColor="#000" 
            />
        <TextView 
            android:id="@+id/balance" 
            android:layout_width="fill_parent" 
            android:layout_height="20dip" 
            android:gravity="right" 
            android:textColor="#000" 
            />
    </LinearLayout>

    <ListView 
        android:id="@android:id/list"
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent" 
        android:textSize="10sp" 
        android:layout_height="fill_parent" 
        android:layout_weight="1"
        android:listSelector="@drawable/custom_row"
        android:background="@drawable/custom_listview"
        android:dividerHeight="0dip"
        android:cacheColorHint="#FFFFFF"
        android:fadingEdge="none"
        android:divider="#FFFFFF" 
        />
    <TextView 
        android:id="@+id/gameCost" 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" 
        android:text="@string/gameCost_not_finished"
        android:textColor="#000"  
        android:paddingTop="10dip"
        />
    <Button 
        android:id="@+id/update_button" 
        android:text="@string/placebet_button"
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content"
        style="@style/whiteText" 
        android:background="@drawable/custom_button" 
        />
</LinearLayout>
    
已邀请:
对于这种情况,您应该使用RelativeLayout而不是LinearLayout。尝试这样的事情:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" 
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    style="@style/defaultBackground" 
    >
    <LinearLayout 
        android:id="@+id/header"
        android:layout_height="wrap_content" 
        android:layout_width="fill_parent"
        android:layout_alignParentTop="true" 
        android:orientation="horizontal"
        android:paddingBottom="10dip"
        >
        <TextView 
            android:id="@+id/roundInfo" 
            android:layout_width="wrap_content" 
            android:layout_height="20dip" android:textColor="#000" 
            />
        <TextView 
            android:id="@+id/balance" 
            android:layout_width="fill_parent" 
            android:layout_height="20dip" 
            android:gravity="right" 
            android:textColor="#000" 
            />
    </LinearLayout>

    <LinearLayout
        android:id="@+id/footer"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:orientation="vertical"
        >
        <TextView 
            android:id="@+id/gameCost" 
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" 
            android:text="@string/gameCost_not_finished"
            android:textColor="#000"  
            android:paddingTop="10dip"
            />
        <Button 
            android:id="@+id/update_button" 
            android:text="@string/placebet_button"
            android:layout_width="fill_parent" 
            android:layout_height="wrap_content"
            style="@style/whiteText" 
            android:background="@drawable/custom_button" 
            />
    </LinearLayout>

    <ListView 
        android:id="@android:id/list"
        android:layout_width="fill_parent" 
        android:textSize="10sp" 
        android:layout_height="fill_parent" 
        android:layout_above="@id/footer"
        android:layout_below="@id/header"
        android:listSelector="@drawable/custom_row"
        android:background="@drawable/custom_listview"
        android:dividerHeight="0dip"
        android:cacheColorHint="#FFFFFF"
        android:fadingEdge="none"
        android:divider="#FFFFFF" 
        />
</RelativeLayout>
基本上,将根布局更改为RelativeLayout,并将内容分为三个区域:标题,正文,页脚。保持标题不变,在水平LinearLayout中,并将其设置为alignParentTop。因为它只设置为wrap_content,所以我们不必担心权重或任何东西。然后,将应该位于底部的其他固定项目(gameCost文本和placeBet按钮)放入用作页脚的垂直LinearLayout。将其设置为alignParentBottom。最后,声明ListView的高度为fill_parent。这将占用剩余空间,但为了使其保持在页眉和页脚的范围内,我们添加了layout_above和layout_below参数。希望这可以帮助!     

要回复问题请先登录注册