Android 4.4系统 - 半透明状态/导航栏 - fitsSystemWindows / clipToPadding不通过片段交易工作片段、不通过、状态、工作

2023-09-04 23:49:52 作者:那伤很唯美

当从全新的Andr​​oid 4.4奇巧的API使用半透明状态和导航栏,设置 fitsSystemWindows =真正的 clipToPadding =假 的ListView 作品最初。 fitsSystemWindows =真正的保持在动作栏和导航栏上面的列表中, clipToPadding =假允许列表到透明导航栏下滚动并使得在列表中的最后一个项目向上滚动足够远传递导航栏。

When using the translucent status and navigation bars from the new Android 4.4 KitKat APIs, setting fitsSystemWindows="true" and clipToPadding="false" to a ListView works initially. fitsSystemWindows="true" keeps the list under the action bar and above the navigation bar, clipToPadding="false" allows the list to scroll under the transparent navigation bar and makes the last item in the list scroll up just far enough to pass the navigation bar.

不过,当你更换另一内容片段通过 FragmentTransaction 的效果 fitsSystemWindows 消失和碎片云的操作栏和导航栏的下方。

However, when you replace the content with another Fragment through a FragmentTransaction the effect of fitsSystemWindows goes away and the fragment goes under the action bar and navigation bar.

我的演示源$ C ​​$ C一codeBase的这里还有一个可下载的APK为例:https://github.com/afollestad/kitkat-transparency-demo.要明白我在说什么,打开运行奇巧的设备演示程序,点击列表中的项目(这将打开另一个活动),并点击在打开的新的活动项目。替换内容的片段进入下操作栏和clipToPadding无法正常工作(导航栏包括在列表中的最后一个项目,当你滚动一路下跌)。

I have a codebase of demo source code here along with a downloadable APK as an example: https://github.com/afollestad/kitkat-transparency-demo. To see what I'm talking about, open the demo app from a device running KitKat, tap an item in the list (which will open another activity), and tap an item in the new activity that opens. The fragment that replaces the content goes under the action bar and clipToPadding doesn't work correctly (the navigation bar covers the last item in the list when you scroll all the way down).

任何想法?任何需要澄清?我张贴的之前和之后的截图我个人的应用程序为我的老板正在开发中。

Any ideas? Any clarification needed? I posted the before and after screenshots of my personal app being developed for my employer.

推荐答案

我用我用我的半透明的状态栏的设置颜色库解决了这个问题。

I solved the issue by using the library I use the set the color of my translucent status bar.

SystemBarConfig 类SystemBarTint的(这里https://github.com/jgilfelt/SystemBarTint#systembarconfig)让你得到我设置为填充到列表中的每个片段的插图,以及名单上的使用 clipToPadding =假

The SystemBarConfig class of SystemBarTint (as seen here https://github.com/jgilfelt/SystemBarTint#systembarconfig) lets you get insets which I set as the padding to the list in every fragment, along with the use of clipToPadding="false" on the list.

我有什么,我对这个职位做了详细介绍:http://mindofaandroiddev.word$p$pss.com/2013/12/28/making-the-status-bar-and-navigation-bar-transparent-with-a-listview-on-android-4-4-kitkat/

I have details of what I've done on this post: http://mindofaandroiddev.wordpress.com/2013/12/28/making-the-status-bar-and-navigation-bar-transparent-with-a-listview-on-android-4-4-kitkat/