Android:RecyclerLayout正在添加默认填充
我正在尝试使用RecyclerLayout创建一个折叠工具栏布局 问题是,当我在运行时膨胀布局时,它自己添加了一个默认的填充 以下是我的布局XML:Android:RecyclerLayout正在添加默认填充,android,android-recyclerview,recyclerview-layout,Android,Android Recyclerview,Recyclerview Layout,我正在尝试使用RecyclerLayout创建一个折叠工具栏布局 问题是,当我在运行时膨胀布局时,它自己添加了一个默认的填充 以下是我的布局XML: activity\u profile.xml <?xml version="1.0" encoding="utf-8"?> <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/an
activity\u profile.xml
<?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"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="180dp"
android:fitsSystemWindows="true"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<ImageView
android:id="@+id/header"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:scaleType="centerCrop"
app:layout_collapseMode="parallax" />
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.design.widget.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
app:layout_anchor="@+id/appbar"
app:layout_anchorGravity="bottom|center|end" />
</android.support.design.widget.CoordinatorLayout>
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
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.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorProfileStatsBackground"
app:layout_constraintBottom_toTopOf="@+id/guideline">
</android.support.constraint.ConstraintLayout>
<android.support.constraint.Guideline
android:id="@+id/guideline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.25" />
</android.support.constraint.ConstraintLayout>
输出:
终于解决了问题 问题在于
AppBarLayout中的android:fitsystemwindows=“true”
我做了一些研究,发现了一篇文章,其中描述了此属性的默认行为是它设置视图的填充,以确保内容不会覆盖系统窗口。添加当前输出和预期输出的屏幕截图,以便更好地理解尝试删除此
android:paddingStart=“-20dp”
@AkshaySingh我已经尝试了你的代码我没有得到任何填充尝试协调器布局高度wrap\u内容
而不是match\u parent
@VishvaDave:我的预览与预期相同,仅在设备上呈现此填充,这是wierd。