我是Android開發的初學者,我正嘗試創建一個包含不同佈局的水平滾動視圖。android水平滾動視圖
我面對的錯誤是:horozontal滾動視圖只能託管一個直接的孩子。 請提前
<HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tool"
android:id="@+id/horizontalScrollView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:fillViewport="true" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:background="#ff0000">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:background="#ff0000">
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:background="#00ff00">
</LinearLayout>
</LinearLayout>
</HorizontalScrollView>
你能更精確地定義你的問題嗎?你的意思是不同的佈局? –
我會將每個佈局視爲一個視圖 –
關鍵是這個佈局沒有任何問題。一切都被恰當地封裝。一切都在一個LinearLayout中,因爲它應該在HorizontalScrollView中。無論您在一個LinearLayout中放入多少東西,它們都會向左/向右滾動。 –