0
我正在尋找一個解決方案來設置滾動視圖中的多個行。Android如何安排多個行在一個HorizontalScrollView
我有15個按鈕(3 * 5),並且想向右滾動,所以還有另外15個按鈕。
我已經得到:所有的按鈕都在一個巨大的行(至少,滾動iself工作)。
然後我試圖設置的最高層(XML線#1)在HorizontalScrollView幷包含3個進一步LinearLayouts所以樹看起來像這樣的LinearLayout後:
<HorizontalScrollView
<LinearLayout
<LinearLayout
(buttonABCDEF)
</LinearLayout>
<LinearLayout
(button)
</LinearLayout>
<LinearLayout
(button56789)
</LinearLayout>
</LinearLayout>
</HorizontalScrollView>
我能得到什麼,然後是一個(〜80x80)的矩形(ScrollView中的線性佈局),它顯示了一個文本(我的佈局中的第一個視圖)和一個按鈕(buttonA - 第一個)換成新的產品線。 (字母數量=行數=按鈕高度)。這是不可滾動的。
我想只發布相關的代碼。注意:安卓佈局的東西是不是對你很重要,因爲它不是以線性佈局工作:
<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>
非常感謝您的幫助。