基本上我有一個水平滾動視圖,通過監視onTouch事件我正在分頁(即:滾動視圖(頁面)的每個可見部分「點擊」滾動到下一個,而不僅僅是具有標準的ScrollView
。請參閱iOS中的分頁滾動視圖)。horizontalscrollview設置子元素來填充horizontalscrollview的寬度
現在我想找到一種方法來讓內部子代繼承與滾動視圖相同的寬度(設置爲"fill_parent"
)。
這裏是我的XML的幫助:
<HorizontalScrollView
android:id="@+id/scrollview"
android:layout_height="0dp"
android:layout_width="fill_parent"
android:layout_weight="1"
android:background="@drawable/scrollviewbg">
<LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="fill_parent">
<ImageView
android:src="@drawable/content1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<ImageView
android:src="@drawable/content2"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<ImageView
android:src="@drawable/content3"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</HorizontalScrollView>
正如你可以看到滾動視圖設置爲寬度fill_parent
並且裏面有它LinearLayout
。現在有三個圖像的寬度和高度與屏幕寬度相似,但我想要做的是更改爲3 LinearLayout
s。
每個LinearLayout
都需要繼承與滾動視圖相同的寬度,這樣當我的代碼被應用時,每個代碼都會佔用整個「頁面」。
我該怎麼做?這是我將不得不使用代碼嗎?我需要什麼代碼?
謝謝。
是容易得多。感謝那。 :) –
我沒有該選項使用支持庫,我們可以在scrollview中執行 – user606669