スクロールビューに複数の行を設定するソリューションを探しています。
15 個のボタン (3*5) があり、右にスクロールして、別の 15 個のボタンがあるようにします。
私がすでに得たもの:すべてのボタンが1つの巨大な行にあります(少なくとも、スクロール自体は機能しました)。
次に、HorizontalScrollView を最上位レイヤー (XML の 1 行目) に設定しようとしました。その後、さらに 3 つの LinearLayouts を含む LinearLayout を設定して、ツリーが次のようになるようにしました。
<HorizontalScrollView
<LinearLayout
<LinearLayout
(buttonABCDEF)
</LinearLayout>
<LinearLayout
(button01234)
</LinearLayout>
<LinearLayout
(button56789)
</LinearLayout>
</LinearLayout>
</HorizontalScrollView>
次に得られるのは、テキスト (私のレイアウトの最初のビュー) とボタン (buttonA - 最初のビュー) を表示する (~80x80) の長方形 (ScrollView の線形レイアウト) です。すべての文字が新しい行に書き込まれます。(文字数=行数=ボタンの高さ)。これはまったくスクロールできません。
関連するコードのみを投稿しようとしています。注: android:layout は線形レイアウトでは機能しないため、重要ではありません。
<HorizontalScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:screenOrientation="landscape"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/horizontalScrollView1"
tools:context=".MainActivity"
android:background="@android:color/black"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation='vertical' >
android:layout_width="9dp"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
android:layout_width="9dp"
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginTop="0dp"
android:textColor="@android:color/white"
android:text="text"
android:textAppearance="?android:attr/textAppearanceMedium" />
<Button
android:id="@+id/buttonA"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/buttonB"
android:layout_toRightOf="@+id/textView1"
android:width="70dp"
android:text="A" />
<Button
android:id="@+id/buttonE"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/buttonD"
android:layout_alignBottom="@+id/buttonD"
android:layout_toRightOf="@+id/buttonD"
android:width="70dp"
android:text="B" />
<Button
android:id="@+id/buttonF"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/buttonE"
android:layout_alignBottom="@+id/buttonE"
android:layout_toRightOf="@+id/buttonE"
android:text="C" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<Button
android:id="@+id/button0"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:background="@drawable/eins"
android:text="0" />
/LinearLayout>
/LinearLayout>
</HorizontalScrollView>
助けてくれてどうもありがとう。