jai*_*rik 7 android android-animation android-actionbar
我试图动画我的工具栏(用作ActionBar)在滚动后隐藏自己.我使用以下代码翻译工具栏 -
toolbar.animate().translationYBy(toolbar.getBottom()*(-1));
Run Code Online (Sandbox Code Playgroud)
但是,在动画之后,之前工具栏占用的空间变为白色并保持不变.
我希望工具栏下方的内容向上移动并占据工具栏留下的空间.
工具栏动画后出现 \xe2\x80\x99s 白色背景的原因是它嵌入布局中的方式。
\n\n有几种方法可以实现这一目标:
\n\n让工具栏覆盖内容
\n\n使用FrameLayout保存工具栏和活动内容。
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"\n android:layout_width="match_parent"\n android:layout_height="match_parent">\n\n <ImageView\n android:id="@+id/picture"\n android:layout_width="match_parent"\n android:layout_height="match_parent"\n android:scaleType="centerCrop"\n android:src="@drawable/jokic" />\n\n <android.support.v7.widget.Toolbar\n android:id="@+id/toolbar"\n android:layout_width="match_parent"\n android:layout_height="wrap_content"\n android:background="@android:color/holo_blue_dark" />\n\n</FrameLayout>\nRun Code Online (Sandbox Code Playgroud)将工具栏保持在内容上方
\n\n当您为工具栏设置动画时,您还必须为活动的布局设置动画以取代它的位置。实施细节将取决于您所展示的内容。如需RecyclerView查看此博客
隐藏ActionBar
只需请求隐藏操作栏getSupportActionBar().hide()即可重绘窗口。
另外,如果您想要进行全屏沉浸式体验活动,这应该涵盖了这一点。
\n| 归档时间: |
|
| 查看次数: |
731 次 |
| 最近记录: |