隐藏 RecyclerView 上的工具栏滚动导致文本移动到通知栏
Hide toolbar on RecyclerView scroll causes text to move into notification bar
在我刚开始的应用程序中,我有一个 RecyclerView。
滚动 RecyclerView 时,我使用以下代码隐藏工具栏:
app:layout_scrollFlags="scroll|enterAlways"
滚动时,工具栏会移动,但它的文本会滑入通知托盘而不是消失。
通知托盘中图像的顶部显示 HarHar,然后在末尾显示设置按钮。
这方面的一个例子是:
Image of toolbar in notification tray
工具栏的代码是:
<?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="true"
tools:context="com.harhar.harhar.MainActivity">
<android.support.design.widget.AppBarLayout
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:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay"
app:layout_scrollFlags="scroll|enterAlways"
/>
</android.support.design.widget.AppBarLayout>
<include layout="@layout/content_main" />
<android.support.v4.view.ViewPager
android:id="@+id/viewPager"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="@dimen/fab_margin"
android:src="@android:drawable/ic_dialog_email" />
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerList"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
/>`
</android.support.design.widget.CoordinatorLayout>
如果有人能提供帮助,我将不胜感激。
谢谢。
if (canHelpMe()){
eternallyGrateful();
}else if(needExtraInformation()){
letMeKnow();
}else{
reallySad();
}
在不同的 XML 文件中添加一个工具栏布局,然后包含该 XML 文件即可,
或删除 app:layout_scrollFlags="scroll|enterAlway
<android.support.v7.widget.Toolbar 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:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay">
</android.support.v7.widget.Toolbar>
您好,从 CoordinatorLayout 中删除 android:fitsSystemWindows="true"
。
所以你的 CoordinatorLayout 看起来像这样
例如
<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"
tools:context="com.harhar.harhar.MainActivity">
如果问题仍然存在,请告诉我
在我刚开始的应用程序中,我有一个 RecyclerView。 滚动 RecyclerView 时,我使用以下代码隐藏工具栏:
app:layout_scrollFlags="scroll|enterAlways"
滚动时,工具栏会移动,但它的文本会滑入通知托盘而不是消失。
通知托盘中图像的顶部显示 HarHar,然后在末尾显示设置按钮。
这方面的一个例子是:
Image of toolbar in notification tray
工具栏的代码是:
<?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="true"
tools:context="com.harhar.harhar.MainActivity">
<android.support.design.widget.AppBarLayout
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:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay"
app:layout_scrollFlags="scroll|enterAlways"
/>
</android.support.design.widget.AppBarLayout>
<include layout="@layout/content_main" />
<android.support.v4.view.ViewPager
android:id="@+id/viewPager"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="@dimen/fab_margin"
android:src="@android:drawable/ic_dialog_email" />
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerList"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
/>`
</android.support.design.widget.CoordinatorLayout>
如果有人能提供帮助,我将不胜感激。 谢谢。
if (canHelpMe()){
eternallyGrateful();
}else if(needExtraInformation()){
letMeKnow();
}else{
reallySad();
}
在不同的 XML 文件中添加一个工具栏布局,然后包含该 XML 文件即可,
或删除 app:layout_scrollFlags="scroll|enterAlway
<android.support.v7.widget.Toolbar 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:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay">
</android.support.v7.widget.Toolbar>
您好,从 CoordinatorLayout 中删除 android:fitsSystemWindows="true"
。
所以你的 CoordinatorLayout 看起来像这样
例如
<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"
tools:context="com.harhar.harhar.MainActivity">
如果问题仍然存在,请告诉我