RecyclerView 在默认 TitleBar 后面启动
RecyclerView starts behind default TitleBar
要求是在 TitleBar 和 BottomNavigationView 之间有一个 RecylerView。但是,RecyclerView 从 TitleBar 后面开始。
XML:
<?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:id="@+id/hs_clayout"
tools:context="com.sd.snafis.cards.HomeScreen" >
<android.support.design.widget.BottomNavigationView
android:id="@+id/bottom_navigation"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
app:itemBackground="@color/colorPrimary"
app:itemIconTint="@android:color/black"
app:itemTextColor="@android:color/darker_gray"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:menu="@menu/bottom_navigation_main" />
<android.support.v7.widget.RecyclerView
android:id="@+id/rv"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
app:layout_constraintBottom_toTopOf="@id/bottom_navigation" />
</android.support.constraint.ConstraintLayout>
截图:
如您所见,第一张卡片位于标题栏下方。我尝试将 marginTop 设置为 RecyclerView,但它不起作用。更喜欢使用 ConstraintLayout 的解决方案,而不是更改布局
添加android:layout_marginTop="?attr/actionBarSize"
或android:paddingTop="?attr/actionBarSize"
在 xml 中 RecyclerView
您是否在 activity 主题中设置了 <item name="windowActionBarOverlay">true</item>
?如果已设置,您可以将其删除或将其值设置为 false。
可以在ConstraintLayout中添加android:fitsSystemWindows="true"
是否windowActionBarOverlay
设置为true。
要求是在 TitleBar 和 BottomNavigationView 之间有一个 RecylerView。但是,RecyclerView 从 TitleBar 后面开始。 XML:
<?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:id="@+id/hs_clayout"
tools:context="com.sd.snafis.cards.HomeScreen" >
<android.support.design.widget.BottomNavigationView
android:id="@+id/bottom_navigation"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
app:itemBackground="@color/colorPrimary"
app:itemIconTint="@android:color/black"
app:itemTextColor="@android:color/darker_gray"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:menu="@menu/bottom_navigation_main" />
<android.support.v7.widget.RecyclerView
android:id="@+id/rv"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
app:layout_constraintBottom_toTopOf="@id/bottom_navigation" />
</android.support.constraint.ConstraintLayout>
截图:
如您所见,第一张卡片位于标题栏下方。我尝试将 marginTop 设置为 RecyclerView,但它不起作用。更喜欢使用 ConstraintLayout 的解决方案,而不是更改布局
添加android:layout_marginTop="?attr/actionBarSize"
或android:paddingTop="?attr/actionBarSize"
在 xml 中 RecyclerView
您是否在 activity 主题中设置了 <item name="windowActionBarOverlay">true</item>
?如果已设置,您可以将其删除或将其值设置为 false。
可以在ConstraintLayout中添加android:fitsSystemWindows="true"
是否windowActionBarOverlay
设置为true。