3

我在垂直 ScrollView 内的 ViewPager 中有标签。水平滑动成功执行。当我尝试垂直滑动时,没有任何反应。

片段活动布局

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:background="@color/background_all_screen">

<RelativeLayout
    android:id="@+id/RelativeLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/border_white"
    android:orientation="vertical">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:layout_alignParentBottom="true"
        android:id="@+id/llButtons">
        <Button
            android:id="@+id/btnBack"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="@string/all"
            android:onClick="onClickAll"
            style="@style/button.blue"
            android:layout_weight="1" />

    </LinearLayout>

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@id/llButtons"
        android:fillViewport="true">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
                xmlns:app="http://schemas.android.com/apk/res-auto"
                android:orientation="vertical" android:layout_width="match_parent"
                android:layout_height="match_parent">

                <com.astuetz.PagerSlidingTabStrip
                    android:id="@+id/tabs"
                    android:layout_width="match_parent"
                    android:layout_height="48dip"
                    style="@style/PagerSlidingTabStrip"
                    app:pstsShouldExpand="true"/>

                <android.support.v4.view.ViewPager
                    android:id="@+id/pager"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"/>

            </LinearLayout>

        </LinearLayout>
    </ScrollView>

</RelativeLayout>
</LinearLayout>

可能我在 ScrollView 和 ViewPager 之间存在冲突。

在片段中使用 ScrollViews 的更新 解决方案很好,但我想要这样的东西:

用户可以看到标签 用户看不到标签

用户在第二个屏幕截图中看不到标签内容。

4

2 回答 2

0

我认为您应该以这种方式更改布局:

因为您在 scrollView 中没有任何小部件,并且我认为一切都在您的片段布局中,所以将您的滚动视图移动到您发送到 viewpager 并使其成为根的每个片段的布局中。所以这样每个片段都会垂直滚动,您也可以通过 viewpager 更改它们。

希望有所帮助!

于 2014-08-09T01:34:44.653 回答
0

你真的需要在滚动视图中有一个视图寻呼机吗?我的建议是使用滚动视图作为 viewpager 片段的布局容器。

于 2014-08-08T20:15:04.880 回答