【发布时间】:2014-07-14 14:24:23
【问题描述】:
我正在尝试在 Android 4.4+ 上制作透明状态栏 我知道如何通过定义自己的风格来使其透明:
<style name="Theme.MyTheme" parent="Theme.MyTheme.Base">
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">true</item> </style>
我在这里找到: https://stackoverflow.com/a/20573595/2633630
问题是当状态栏是透明的时,它与动作栏的颜色不匹配,并且看到了后台的活动:
所以我发现我可以在我在这里找到的布局中使用 android:fitsSystemWindows="true" 和 android:clipToPadding="false" http://mindofaandroiddev.wordpress.com/2013/12/28/making-the-status-bar-and-navigation-bar-transparent-with-a-listview-on-android-4-4-kitkat/
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/background_darkRed"
android:fitsSystemWindows="true"
android:clipToPadding="false"
tools:context="com.sandak.......">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
....
这解决了透明状态栏的顶部问题,看起来还可以。不幸的是,系统按钮的“导航栏”底部有问题,它是红色的,并且我希望它不透明:
我尝试了所有可能的变体来实现工作结果,但我不知道如何解决它。我唯一可行的解决方案是将顶部填充设置为根元素约 60dp。但是这个解决方案很丑陋,而且在不同的设备上看起来可能会有所不同,并且可能无法正常工作。
我在 Google Play 上发现了一些应用程序,它们在透明背景下运行良好,所以我很好奇它们是如何使其工作的。
例如: https://play.google.com/store/apps/details?id=com.trello 和其他一些人
【问题讨论】:
-
当我像你一样将
android:windowTranslucentStatus/Navigation设置为 true 时,背景只是半透明的。你有没有做任何不同的事情来获得你在截图中的那种漂亮的暗渐变效果?
标签: android android-layout user-experience