我試圖使透明狀態欄上的Android 4.4+ 我知道如何使它透明通過定義自己的風格:的Android,如何使一個透明的狀態欄正確
<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 =「真」和android:clipToPadding在我的佈局,我發現這裏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時,背景只是半透明的。你做了什麼不同的事情來獲得你截圖中的黑暗漸變效果? – JMRboosties