小编Bur*_*ürk的帖子

ScrollView不会滚动片段

我搜索了我的问题,并在stackoverflow中读取类似的问题,但我没有解决任何方式.

我有一个带有coordinatorLayout(main.xml)的布局和一个带有relativeLayout(fragment.xml)的片段

main.xml中

<android.support.design.widget.AppBarLayout
    android:id="@+id/appbar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:theme="@style/AppTheme.AppBarOverlay">

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:paddingRight="16dp"
        app:layout_scrollFlags="scroll|enterAlways"
        app:popupTheme="@style/AppTheme.PopupOverlay">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                android:layout_weight="1">
                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="40dp"
                    android:text="FRAGMENT TITLE"
                    android:textSize="20sp"
                    android:textColor="@color/colorWhite"
                    android:id="@+id/main_toolbar_title"
                    android:gravity="center_vertical" />
            </LinearLayout>
        </LinearLayout>
    </android.support.v7.widget.Toolbar>

    <android.support.design.widget.TabLayout
        android:id="@+id/tabs"
        android:background="@color/colorWhite"
        android:layout_width="match_parent"
        android:layout_height="60dp" />
</android.support.design.widget.AppBarLayout>

<android.support.v4.view.ViewPager
    android:id="@+id/container"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior" />
Run Code Online (Sandbox Code Playgroud)

fragment.xml之

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="10dp"
android:background="#f3f3f3">

<ScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent">

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

        <android.support.v7.widget.CardView
            android:id="@+id/card_view"
            android:layout_gravity="center"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            card_view:contentPadding="1dp"
            card_view:cardCornerRadius="2dp">

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

                <Button
                    android:layout_width="match_parent"
                    android:layout_height="66dp" …
Run Code Online (Sandbox Code Playgroud)

android scrollview android-layout android-fragments

1
推荐指数
1
解决办法
983
查看次数