基本上,我有一个水平滚动视图,通过监视我正在分页的onTouch事件(即:滚动时滚动视图(页面)的每个可见部分“点击”到下一个部分),而不仅仅是有一个标准的ScrollView。请参阅iOS中的分页滚动视图)。
现在我想找到一种方法,让内部的孩子继承与scrollview (设置为"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>正如您所看到的,scrollview被设置为width fill_parent,并且里面有一个LinearLayout。现在有三个图像,它们的宽度和高度设置与屏幕的宽度相似,但我想做的是将其更改为3 LinearLayouts。
每个LinearLayout都需要继承与滚动视图相同的宽度,以便在应用我的代码时,每一个都占据一个完整的“页面”。
我该怎么做呢?这是我必须使用代码来做的事情吗?我需要什么代码?
谢谢。
发布于 2011-08-29 21:53:23
我知道这不是直接的答案,但在Compatibility Package中使用ViewPager实现分页功能要容易得多。您可以在samples文件夹中找到一个示例(请参阅src/com/example/android/supportv4/app/FragmentPagerSupport.java获取源代码)。
发布于 2018-01-25 17:57:45
试试这个:android:fillViewport="true"
<HorizontalScrollView
android:fillViewport="true"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_gravity="right"
android:background="@drawable/black_border"
android:id="@+id/displayText"
android:layout_width="match_parent"
android:scrollHorizontally="true"
android:layout_height="wrap_content"
android:gravity="right"
android:padding="20dp"
android:text=""
android:textSize="20sp" />
</HorizontalScrollView>在水平滚动视图中,我有一个文本视图,您可以尝试图像视图
发布于 2011-08-29 22:25:03
将所有layout_height参数设置为fill_parent。然后你应该会看到全屏的图像。
https://stackoverflow.com/questions/7230913
复制相似问题