在CoordinatorLayout(root)下面有一个估计56dp的空白,如图所示。但是,只有在排除故障时出现AppbarLayout时才会出现这种情况。
我不知道如何修复它我试过fitSystemWindows="true"
但这不起作用。为什么这样做? (如果我没有意义,请说)
这是我的布局代码。
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout 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="match_parent"
android:fitsSystemWindows="false">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="56dp">
<android.support.design.widget.CollapsingToolbarLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:toolbarId="@+id/toolbar">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"></android.support.v7.widget.Toolbar>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="fill_vertical"
android:background="@color/colorS50Alpha"
android:clipToPadding="false"
app:layout_behavior="android.support.design.widget.AppBarLayout$ScrollingViewBehavior">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/toolbar5"
android:layout_centerHorizontal="true"
android:layout_gravity="fill_vertical"
android:fillViewport="false">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="fill_vertical"
android:orientation="vertical">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="fill_vertical">
<android.support.v7.widget.RecyclerView
android:id="@+id/lvProfilePosts"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/tbProfiletabs"
android:visibility="visible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tbProfiletabs"
app:layout_constraintVertical_bias="0.0" />
<android.support.design.widget.TabLayout
android:id="@+id/tbProfiletabs"
android:layout_width="0dp"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:layout_marginBottom="283dp"
android:background="@color/colorS50Alpha"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/relativeLayout5"
app:layout_constraintVertical_bias="0.0"
app:tabSelectedTextColor="@android:color/white"
app:tabTextColor="@color/colorSearch">
<android.support.design.widget.TabItem
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Left" />
<android.support.design.widget.TabItem
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Center" />
</android.support.design.widget.TabLayout>
<ImageView
android:id="@+id/ivProfileBackphoto"
android:layout_width="0dp"
android:layout_height="320dp"
android:background="@drawable/background_signinandregister"
android:scaleType="centerCrop"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0"
app:srcCompat="@color/colorProfileBack" />
<RelativeLayout
android:id="@+id/relativeLayout5"
android:layout_width="0dp"
android:layout_height="150dp"
android:background="@drawable/shadow_profile_01"
app:layout_constraintBottom_toBottomOf="@+id/ivProfileBackphoto"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="1.0">
</RelativeLayout>
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/ivProfilephoto"
android:layout_width="160dp"
android:layout_height="160dp"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp"
android:scaleType="centerCrop"
app:layout_constraintBottom_toBottomOf="@+id/ivProfileBackphoto"
app:layout_constraintHorizontal_bias="0.498"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.361" />
<TextView
android:id="@+id/tvName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp"
android:fontFamily="sans-serif"
android:text="Foster The People"
android:textAppearance="@style/TextAppearance.AppCompat"
android:textColor="@android:color/white"
android:textSize="30sp"
app:layout_constraintBottom_toBottomOf="@+id/ivProfileBackphoto"
app:layout_constraintHorizontal_bias="0.497"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/ivProfilephoto"
app:layout_constraintVertical_bias="0.0" />
<TextView
android:id="@+id/tvDescription"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="40dp"
android:layout_marginLeft="40dp"
android:layout_marginRight="40dp"
android:layout_marginStart="40dp"
android:layout_marginTop="1dp"
android:text="I like bacon and cheese sandwiches"
android:textAlignment="center"
android:textColor="@color/colorGrey"
android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="@+id/ivProfileBackphoto"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tvName"
app:layout_constraintVertical_bias="0.0" />
<ImageView
android:id="@+id/ivAddFriend"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
app:layout_constraintBottom_toBottomOf="@+id/relativeLayout5"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@+id/ivProfilephoto"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.418"
app:srcCompat="@drawable/addfriend02" />
<ImageView
android:id="@+id/ivRemoveFriend"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
app:layout_constraintBottom_toBottomOf="@+id/relativeLayout5"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@+id/ivProfilephoto"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.418"
app:srcCompat="@drawable/removefriend02" />
</android.support.constraint.ConstraintLayout>
</LinearLayout>
</ScrollView>
</android.support.v4.widget.NestedScrollView>
我不知道如何进一步详细说明。任何帮助表示赞赏。
答案 0 :(得分:0)
设置
android:fillViewport="false"
到true
在Scrollview中
并删除此
app:layout_scrollFlags="scroll|exitUntilCollapsed"
如果您不想滚动工具栏和滚动视图。