我有一个水平滚动视图,通过监控onTouch事件来分页(即:每个可见的滚动视图部分(页面)在滚动时“点击”到下一个,而不是只有标准的ScrollView
。请参见iOS中的分页滚动视图)。
现在我想找到一种方法,使内部子元素继承与滚动视图相同的宽度(该宽度设置为"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
进行更改。每个
LinearLayout
需要继承与滚动视图相同的宽度,以便在应用我的代码时,每个都占据整个“页面”。我该如何做?这是我必须使用代码完成的事情吗?我需要哪些代码?
谢谢。