Scrollview -> Relativelayout -> TabLayout 不要滚动整个布局

Scrollview -> Relativelayout -> TabLayout don't scroll whole layout

我正在尝试滚动整个布局,但我不能,只有 tablayout 滚动和 tablayout 上方的相对布局它们无法滚动,如何修复它,我正在尝试制作像 instagram 配置文件或帐户片段页面...帮助修复它...在此先感谢,我在 tablayout framelayout 下使用而不是 viewpager 并附加 framelayout 片段第一个选项卡我可以单击然后该片段使用滚动,线性和 recyclerview 片段调用然后整个布局滚动,但我可以单击另一个第二个选项卡,然后该片段仅使用线性和网格视图,该片段调用然后半布局滚动,我在哪里错了请告诉我...

<?xml version="1.0" encoding="utf-8"?>
    <ScrollView
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fillViewport="true"
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto">
        <RelativeLayout
            android:id="@+id/relativelayout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
            <LinearLayout
                android:id="@+id/imglayout"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content">
                <de.hdodenhof.circleimageview.CircleImageView
                    android:id="@+id/cvprofile"
                    android:layout_width="86dp"
                    android:layout_height="86dp"
                    app:civ_border_color="#a4a4a4"
                    app:civ_border_width="0.5dp"
                    android:layout_margin="12dp"
                    android:src="@drawable/img" />
            </LinearLayout>
            <LinearLayout
                android:id="@+id/digitlayout"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_toRightOf="@id/imglayout"
                android:layout_marginLeft="12dp"
                android:layout_marginRight="12dp"
                android:layout_marginTop="12dp">
                <TextView
                    android:id="@+id/post"
                    android:layout_weight="1"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:text="100"
                    android:gravity="center"
                    android:textColor="@color/black"
                    android:textSize="16sp"
                    android:textStyle="bold" />
                <TextView
                    android:id="@+id/followers"
                    android:layout_weight="1"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:text="100"
                    android:gravity="center"
                    android:textColor="@color/black"
                    android:textSize="16sp"
                    android:textStyle="bold"/>
                <TextView
                    android:id="@+id/following"
                    android:layout_weight="1"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:text="43"
                    android:gravity="center"
                    android:textColor="@color/black"
                    android:textSize="16sp"
                    android:textStyle="bold"/>
            </LinearLayout>
            <LinearLayout
                android:id="@+id/textlayout"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_toRightOf="@id/imglayout"
                android:layout_below="@id/digitlayout"
                android:layout_marginLeft="12dp"
                android:layout_marginRight="12dp"
                android:layout_marginTop="2dp">
                <TextView
                    android:id="@+id/posts"
                    android:layout_weight="1"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:text="posts"
                    android:gravity="center"
                    android:textSize="16sp" />
                <TextView
                    android:id="@+id/followerss"
                    android:layout_weight="1"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:text="follwers"
                    android:textSize="16sp"
                    android:gravity="center"/>
                <TextView
                    android:id="@+id/followings"
                    android:layout_weight="1"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:text="follwers"
                    android:textSize="16sp"
                    android:gravity="center"/>
            </LinearLayout>  
            <TextView
                android:id="@+id/tvedit"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="@string/edit_profile"
                android:layout_marginLeft="12dp"
                android:layout_marginRight="12dp"
                android:layout_marginTop="10dp"
                android:textSize="15sp"
                android:textStyle="bold"
                android:textColor="@color/black"
                android:background="@drawable/bg_textview"
                android:layout_toRightOf="@id/imglayout"
                android:layout_below="@id/textlayout"
                android:gravity="center_horizontal"/>
           <View
                android:id="@+id/view1"
                android:layout_below="@id/imglayout"
                android:layout_width="match_parent"
                android:layout_height="0.5dp"
                android:background="#b6b6b6" />
            <android.support.design.widget.TabLayout
                android:id="@+id/tabLayout"
                android:layout_below="@id/view1"
                app:tabIndicatorHeight="0dp"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:tabGravity="fill"
                app:tabMode="fixed">
                   <android.support.design.widget.TabItem
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:icon="@drawable/frame1"/>
                    <android.support.design.widget.TabItem
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:icon="@drawable/frame1" />
                    <android.support.design.widget.TabItem
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:icon="@drawable/frame1" />
                    <android.support.design.widget.TabItem
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:icon="@drawable/frame1" />
                </android.support.design.widget.TabLayout>
            <View
                android:id="@+id/view2"
                android:layout_below="@id/tabLayout"
                android:layout_width="match_parent"
                android:layout_height="0.5dp"
                android:background="#b6b6b6" />
            <FrameLayout
                android:id="@+id/framelayout"
                android:layout_below="@id/view2"
                android:layout_width="match_parent"
                android:layout_height="match_parent">
            </FrameLayout>
        </RelativeLayout>
    </ScrollView>

尝试在您的 ScrollView 中添加一个 LinearLayout(ScrollView --> LiearLayout-->RelativeLayout--> ...)。或者只需将 android:fillViewport="true" 添加到您的滚动视图。

尝试将 ScrollView 更改为 NestedScrollView

android.support.v4.widget.NestedScrollView

兄弟,我刚刚将你的代码复制到m xml 并且滚动没有问题......如果你仍然有问题那么只需在scrollview之前添加一个相对布局......就像这样

RelativeLAyout>ScrollView>RelativeLayout

试试这个

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fillViewport="true">

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

<RelativeLayout
    android:id="@+id/relativelayout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <LinearLayout
        android:id="@+id/imglayout"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">

        <de.hdodenhof.circleimageview.CircleImageView
            android:id="@+id/cvprofile"
            android:layout_width="86dp"
            android:layout_height="86dp"
            android:layout_margin="12dp"
            android:src="@drawable/img"
            app:civ_border_color="#a4a4a4"
            app:civ_border_width="0.5dp" />
    </LinearLayout>

    <LinearLayout
        android:id="@+id/digitlayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="12dp"
        android:layout_marginRight="12dp"
        android:layout_marginTop="12dp"
        android:layout_toRightOf="@id/imglayout">

        <TextView
            android:id="@+id/post"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:gravity="center"
            android:text="100"
            android:textColor="@color/black"
            android:textSize="16sp"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/followers"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:gravity="center"
            android:text="100"
            android:textColor="@color/black"
            android:textSize="16sp"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/following"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:gravity="center"
            android:text="43"
            android:textColor="@color/black"
            android:textSize="16sp"
            android:textStyle="bold" />
    </LinearLayout>

    <LinearLayout
        android:id="@+id/textlayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/digitlayout"
        android:layout_marginLeft="12dp"
        android:layout_marginRight="12dp"
        android:layout_marginTop="2dp"
        android:layout_toRightOf="@id/imglayout">

        <TextView
            android:id="@+id/posts"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:gravity="center"
            android:text="posts"
            android:textSize="16sp" />

        <TextView
            android:id="@+id/followerss"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:gravity="center"
            android:text="follwers"
            android:textSize="16sp" />

        <TextView
            android:id="@+id/followings"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:gravity="center"
            android:text="follwers"
            android:textSize="16sp" />
    </LinearLayout>

    <TextView
        android:id="@+id/tvedit"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/textlayout"
        android:layout_marginLeft="12dp"
        android:layout_marginRight="12dp"
        android:layout_marginTop="10dp"
        android:layout_toRightOf="@id/imglayout"
        android:background="@drawable/bg_textview"
        android:gravity="center_horizontal"
        android:text="@string/edit_profile"
        android:textColor="@color/black"
        android:textSize="15sp"
        android:textStyle="bold" />

    <View
        android:id="@+id/view1"
        android:layout_width="match_parent"
        android:layout_height="0.5dp"
        android:layout_below="@id/imglayout"
        android:background="#b6b6b6" />

    <android.support.design.widget.TabLayout
        android:id="@+id/tabLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/view1"
        app:tabGravity="fill"
        app:tabIndicatorHeight="0dp"
        app:tabMode="fixed">

        <android.support.design.widget.TabItem
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:icon="@drawable/frame1" />

        <android.support.design.widget.TabItem
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:icon="@drawable/frame1" />

        <android.support.design.widget.TabItem
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:icon="@drawable/frame1" />

        <android.support.design.widget.TabItem
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:icon="@drawable/frame1" />
    </android.support.design.widget.TabLayout>

    <View
        android:id="@+id/view2"
        android:layout_width="match_parent"
        android:layout_height="0.5dp"
        android:layout_below="@id/tabLayout"
        android:background="#b6b6b6" />

    <FrameLayout
        android:id="@+id/framelayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_below="@id/view2"></FrameLayout>
  </RelativeLayout>
  </LinearLayout>
 </ScrollView>