1

画面の上部に同じ幅の 2 つのボタンがあり、そのすぐ下にスクロール ビューがあるレイアウトを作成しようとしています。UI要素を動的に作成しているため、スクロールビュー内にlinearLayoutがあります。

ボタンは正しく配置されていますが、スクロール ビューが非表示になっているか、スクロール ビュー内の線形レイアウトが非表示になっています。私は何を間違っていますか?LinearLayout に TextView プレースホルダーを作成して、何かが表示されているかどうかを確認しましたが、表示されません。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/EditRecordOuterLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >

 <LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:orientation="horizontal"
    >

    <RelativeLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="match_parent"
        android:layout_weight="1" >

        <RelativeLayout
            android:id="@+id/Bforeground"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:gravity="center" >

            <TextView
                android:id="@+id/cancelButtonText"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:textSize="20dp"
                android:text="Cancel" />

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerVertical="true"
                android:layout_toLeftOf="@id/cancelButtonText"
                android:paddingBottom="10dip"
                android:paddingTop="10dip"
                android:src="@drawable/cancel" />
        </RelativeLayout>
                    <Button
            android:layout_width="fill_parent"
            android:layout_height="match_parent"
            android:layout_alignBottom="@id/Bforeground"
            android:layout_alignLeft="@id/Bforeground"
            android:layout_alignRight="@id/Bforeground"
            android:layout_alignTop="@+id/Bforeground"
            android:onClick="clickedMe"
            android:gravity="center" />
    </RelativeLayout>

    <RelativeLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="match_parent"
        android:layout_weight="1" >

        <RelativeLayout
            android:id="@+id/foreground"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:gravity="center" >

            <TextView
                android:id="@+id/button_text"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:textSize="20dp"
                android:text="Save" />

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerVertical="true"
                android:layout_toLeftOf="@id/button_text"
                android:paddingBottom="10dip"
                android:paddingTop="10dip"
                android:src="@drawable/save" />
        </RelativeLayout>
                    <Button
            android:layout_width="fill_parent"
            android:layout_height="match_parent"
            android:layout_alignBottom="@id/foreground"
            android:layout_alignLeft="@id/foreground"
            android:layout_alignRight="@id/foreground"
            android:layout_alignTop="@+id/foreground"
            android:onClick="clickedMe"
            android:gravity="center" />
    </RelativeLayout>
</LinearLayout>
<ScrollView
    android:id="@+id/editRecordScrollView"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:id="@+id/editRecordLayout"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical" >
                     <TextView
                android:id="@+id/someText"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:textSize="20dp"
                android:text="This text should be showing..." />
    </LinearLayout>
</ScrollView>

とった!あなたたちに感謝します。以下修正版。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/EditRecordOuterLayout"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

     <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:orientation="horizontal"
        >

        <RelativeLayout
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="fill_parent"
            android:layout_height="match_parent"
            android:layout_weight="1" >

            <RelativeLayout
                android:id="@+id/Bforeground"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:gravity="center" >

                <TextView
                    android:id="@+id/cancelButtonText"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_centerInParent="true"
                    android:textSize="20dp"
                    android:text="Cancel" />

                <ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_centerVertical="true"
                    android:layout_toLeftOf="@id/cancelButtonText"
                    android:paddingBottom="10dip"
                    android:paddingTop="10dip"
                    android:src="@drawable/cancel" />
            </RelativeLayout>
                        <Button
                android:layout_width="fill_parent"
                android:layout_height="match_parent"
                android:layout_alignBottom="@id/Bforeground"
                android:layout_alignLeft="@id/Bforeground"
                android:layout_alignRight="@id/Bforeground"
                android:layout_alignTop="@+id/Bforeground"
                android:onClick="clickedMe"
                android:gravity="center" />
        </RelativeLayout>

        <RelativeLayout
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="fill_parent"
            android:layout_height="match_parent"
            android:layout_weight="1" >

            <RelativeLayout
                android:id="@+id/foreground"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:gravity="center" >

                <TextView
                    android:id="@+id/button_text"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_centerInParent="true"
                    android:textSize="20dp"
                    android:text="Save" />

                <ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_centerVertical="true"
                    android:layout_toLeftOf="@id/button_text"
                    android:paddingBottom="10dip"
                    android:paddingTop="10dip"
                    android:src="@drawable/save" />
            </RelativeLayout>
                        <Button
                android:layout_width="fill_parent"
                android:layout_height="match_parent"
                android:layout_alignBottom="@id/foreground"
                android:layout_alignLeft="@id/foreground"
                android:layout_alignRight="@id/foreground"
                android:layout_alignTop="@+id/foreground"
                android:onClick="clickedMe"
                android:gravity="center" />
        </RelativeLayout>
    </LinearLayout>
    <ScrollView
        android:id="@+id/editRecordScrollView"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" >

        <LinearLayout
            xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:tools="http://schemas.android.com/tools"
            android:id="@+id/editRecordLayout"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:orientation="vertical" >

        </LinearLayout>
    </ScrollView>
</LinearLayout>
4

1 に答える 1

2

単一の親レイアウト内にすべての UI 要素を配置する必要があります。トップレベルとして a を引き続き使用することをお勧めしますがLinearLayout、次のように垂直にする必要があります。

android:orientation="vertical"

親の垂直 LinearLayout 内に、上部のボタン用の水平 LinearLayout を配置できますScrollView。それはそれを行う必要があります。

于 2013-03-22T03:18:21.097 に答える