0

さまざまなデバイスで使用すると、ボタンのレイアウトが均等に配置されないというアプリの問題があります。

示されているように、最初のスクリーンショットは、古い、画面の小さい Android スマートフォンで等間隔に配置されたレイアウトを示しています。

ここに画像の説明を入力

Nexus 4 の 2 番目のスクリーンショットは、一番下のボタンの下にある大きな空白が不均一であることを示しています。

ここに画像の説明を入力

レイアウトを均等に設定したと思っていましたが、そうではないようです。

更新: 2 つの線形レイアウトを含むスクロール ビューを設定する方法。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="84dp"
    android:orientation="horizontal" >

    <ImageView
        android:id="@+id/imgLink"
        android:layout_width="78dp"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        android:src="@drawable/appointmentmanimenuicon" />



    <TextView
        android:id="@+id/textView1"
        android:layout_width="match_parent"
        android:layout_height="75dp"
        android:gravity="center"
        android:text="Appointments"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:textSize="30sp" />
</LinearLayout>

     <ScrollView
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:fillViewport="true">


   <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="200dp"
        android:orientation="vertical" >

    <Button
        android:id="@+id/btnaddAppoint"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_margin="50dp"
        android:drawableLeft="@drawable/appointmentmenu"
        android:src="@drawable/appointmentmenu"
        android:text="Add Appointment"
        android:layout_weight="1" />

    </LinearLayout>

       <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="200dp"
        android:orientation="vertical" >
    <Button
        android:id="@+id/btnviewAppoint"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_margin="50dp"
        android:drawableLeft="@drawable/appointviewicon"
        android:src="@drawable/appointviewicon"
        android:text="View Appointments"
        android:layout_weight="1" />
</LinearLayout>
</ScrollView>
</LinearLayout>
4

2 に答える 2

1

ボタンを含むネストされたリニア レイアウトの高さは 400 dp に固定されています。小さなデバイスでは、これにより下部に小さなスペースが残りますが、大きな nexus4 ではそうではありません。

ボタンで線形レイアウトを変更して、高さの値 fill_parent を使用する場合、ヘッダー (連絡先) の下の親レイアウトに残っているスペースにボタンを均等に配置する必要があります。

于 2013-08-15T20:18:19.297 に答える