0

ページ間をスライドできるように、アプリを水平方向にスクロールできるようにしたいと考えています。しかし、Android sdk でこの機能を使用すると、xml レイアウトを親で塗りつぶすことができなくなります。つまり、ボタンとオブジェクトを含めるための全画面表示ができなくなります。

どうすればこれを修正できるか、または代替方法は何ですか?

コードは次のとおりです。

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

    <RelativeLayout
        android:layout_width="348dp"
        android:layout_height="559dp" >

        <ImageButton
            android:id="@+id/imageButton1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_alignParentLeft="true"
            android:layout_marginBottom="341dp"
            android:layout_marginLeft="146dp"
            android:src="@drawable/ic_launcher" />

    </RelativeLayout>


</HorizontalScrollView>
4

1 に答える 1

0

相対レイアウトをLinearLayoutに変更します。垂直ScrollViewと同様に、LinearLayoutを利用します。

これが私のプロジェクトの1つにあるサンプルレイアウトです:

<HorizontalScrollView
            android:id="@+id/horizontalScrollView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:scrollbars="none" >

            <LinearLayout
                android:id="@+id/LinearLayout1"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="horizontal" >

                <Button
                     android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/class_tab" />

                <Button
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/exam" />

                <Button
                    android:id="@+id/button_more"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/more" />

            </LinearLayout>
        </HorizontalScrollView>
于 2012-04-05T02:48:00.637 に答える