1

私は次のようなXMLレイアウトを持っています。TExtビューに続いて、いくつかのチェックボックスとボタンがあります。すべてのチェックボックスを線形レイアウトで囲み、そのためのスクロールビューを設定しました。`下にスクロールした後、ボタンが表示されません。どうすればよいですか?

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


    <TextView />

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

        <LinearLayout>

            <CheckBox />

            <CheckBox />

            <CheckBox/>

            <CheckBox/>

            <CheckBox/>

            <CheckBox/>

            <CheckBox/>

            <CheckBox/>

            <CheckBox />

            <CheckBox/>

            <CheckBox />
        </LinearLayout>
    </ScrollView>

    <Button

    </Button>

</LinearLayout>
4

3 に答える 3

1

スクロール ビューには条件があり、スクロール ビューの子ビューは 1 つだけである必要があります。子ビューには子ビューが含まれる場合があります。

ボタンを表示したい場合は、ビューワイトコンセプトを使用してください

    <LinearLayout
        <TextView
    <ScrollView   
    <LinearLayout
      <CheckBox
        <CheckBox
        <CheckBox
        <CheckBox
        .



        <CheckBox
    LinearLayout>
    ScrollView>
        <Button
 android:layout_weight="1"

    LinearLayout >
于 2012-10-06T11:57:58.003 に答える
0

より良い解決策を得るには、Relativelayout または FrameLayout を使用する必要があります。これは、相対レイアウトを使用するコードです。

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


        <Button
            android:id="@+id/relative_button"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
android:text="hello one"
             >
        </Button>

        <ScrollView
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_above="@id/relative_button"
             >

         <LinearLayout>

                <CheckBox />

                <CheckBox />

                <CheckBox/>

                <CheckBox/>

                <CheckBox/>

                <CheckBox/>

                <CheckBox/>

                <CheckBox/>

                <CheckBox />

                <CheckBox/>

                <CheckBox />
            </LinearLayout>
        </ScrollView>

    </RelativeLayout>
于 2012-10-08T04:07:27.713 に答える
0

次のコードを試してください。ボタンを下に揃え、チェックボックスを含む LinearLayout をボタンの上に揃える必要があります。私はこのコードを試しましたが、うまくいきました。

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

    <TextView
        android:id="@+id/textView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:text="ABC" />

    <ScrollView
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/textView"
        android:layout_above="@+id/button"
        android:orientation="vertical" >

        <LinearLayout
            android:orientation="vertical"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" >

            <CheckBox
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />

            <CheckBox
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />

            <CheckBox
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />

            <CheckBox
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />

            <CheckBox
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />

            <CheckBox
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />

            <CheckBox
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />

            <CheckBox
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />

            <CheckBox
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />

            <CheckBox
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />

            <CheckBox
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />
        </LinearLayout>
    </ScrollView>

    <Button
        android:id="@+id/button"
        android:layout_centerHorizontal="true"
        android:layout_alignParentBottom="true"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

</RelativeLayout>
于 2012-10-08T06:57:05.170 に答える