3

基本上我有一个水平滚动视图,通过监视我正在分页的 onTouch 事件(即:滚动视图(页面)的每个可见部分在滚动时“点击”到下一个,而不仅仅是有一个标准的ScrollView.see paged scrollviews在 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。现在有三个图像的宽度和高度与屏幕的宽度相似,但我想做的是将其更改为 3LinearLayout秒。

每个都LinearLayout需要继承与滚动视图相同的宽度,以便在应用我的代码时每个都占用一整个“页面”。

我该怎么做?这是我必须使用代码做的事情吗?我需要什么代码?

谢谢你。

4

3 回答 3

3

我知道它不是直接的答案,但它更容易让用户ViewPagerCompatibility Package获得分页功能。您可以在文件夹中找到一个示例samples(参见src/com/example/android/supportv4/app/FragmentPagerSupport.java源代码)。

于 2011-08-29T13:53:23.273 回答
1

试试这个: 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>

在水平滚动视图中,我有一个文本视图,你可以尝试图像视图

于 2018-01-25T09:57:45.113 回答
0

将所有layout_height参数设置为fill_parent。然后你应该全屏看到图像。

于 2011-08-29T14:25:02.810 回答