当我试图在 RecyclerView 滚动条上隐藏时,工具栏离开 space
Toolbar leaving space when I tried to hide on RecyclerView scroll
我想在 recyclerView
的卷轴上隐藏我的 toolbar
。它隐藏在卷轴上,但问题是它在隐藏后留下空白space。
我点击下面的链接 -
1 - TutLinks 1
2 -
toolbar.animate().translationY(-toolbar.getBottom()).setInterpolator(new AccelerateInterpolator()).start();
如果您想再次显示它,请致电:
toolbar.animate().translationY(0).setInterpolator(new DecelerateInterpolator()).start();
我已经找到问题并解决了。其实问题出在include tag.
在上面的代码中,我使用了 include 标签,include 标签不能执行工具栏的功能。均值
app:layout_scrollFlags="scroll|enterAlways"
不适用于 include 标签。
如果我直接在 XML 文件中使用带有 scrollFlags 的工具栏,那么一切正常。
或在toolbar.xml中添加layout_scrollFlags
toolbar.xml
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:titleTextColor="#FFFFFF"
app:layout_scrollFlags="scroll|enterAlways"
/>
更改后,我不需要手动隐藏和显示工具栏。
一切正常。
我想在 recyclerView
的卷轴上隐藏我的 toolbar
。它隐藏在卷轴上,但问题是它在隐藏后留下空白space。
我点击下面的链接 -
1 - TutLinks 1
2 -
toolbar.animate().translationY(-toolbar.getBottom()).setInterpolator(new AccelerateInterpolator()).start();
如果您想再次显示它,请致电:
toolbar.animate().translationY(0).setInterpolator(new DecelerateInterpolator()).start();
我已经找到问题并解决了。其实问题出在include tag.
在上面的代码中,我使用了 include 标签,include 标签不能执行工具栏的功能。均值
app:layout_scrollFlags="scroll|enterAlways"
不适用于 include 标签。
如果我直接在 XML 文件中使用带有 scrollFlags 的工具栏,那么一切正常。
或在toolbar.xml中添加layout_scrollFlags
toolbar.xml
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:titleTextColor="#FFFFFF"
app:layout_scrollFlags="scroll|enterAlways"
/>
更改后,我不需要手动隐藏和显示工具栏。
一切正常。