Navigasyon Çekmece yarı saydam Durum Çubuğu üzerinde çalışmıyor
Android proje üzerinde çalışıyorum ve Navigasyon Çekmece başlatıyorum. Yeni Material Design Spec Material Design Checklist okuyorum.
Spec bölmesinden dışarı kaydırın durum çubuğu da dahil olmak üzere her şeyin üstünde yüzer ve yarı-şeffaf Durum Çubuğu üzerinde gerektiğini söylüyor.
Navigasyon benim paneli durum çubuğu ama herhangi bir şeffaflık var onun üzerinde. Bu kodu takip ediyorumBu YÜZDENGoogle geliştiriciler önerilen post spot, How do I use DrawerLayout to display over the ActionBar/Toolbar and under the status bar? yukarıdaki link blog.
Aşağıda XML düzeni
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@ id/my_drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
android:id="@ id/my_awesome_toolbar"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:minHeight="?attr/actionBarSize"
android:background="@color/appPrimaryColour" />
</LinearLayout>
<LinearLayout android:id="@ id/linearLayout"
android:layout_width="304dp"
android:layout_height="match_parent"
android:layout_gravity="left|start"
android:fitsSystemWindows="true"
android:background="#ffffff">
<ListView android:id="@ id/left_drawer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:choiceMode="singleChoice"></ListView>
</LinearLayout>
</android.support.v4.widget.DrawerLayout>
Aşağıda uygulamalar benim tema
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">@color/appPrimaryColour</item>
<item name="colorPrimaryDark">@color/appPrimaryColourDark</item>
<item name="colorAccent">@color/appPrimaryColour</item>
<item name="windowActionBar">false</item>
<item name="windowActionModeOverlay">true</item>
</style>
Aşağıda uygulamalarım v21 tema
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">@color/appPrimaryColour</item>
<item name="colorPrimaryDark">@color/appPrimaryColourDark</item>
<item name="colorAccent">@color/appPrimaryColour</item>
<item name="windowActionBar">false</item>
<item name="windowActionModeOverlay">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">@android:color/transparent</item>
</style>
Aşağıda onCreate yöntemi
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.my_awesome_toolbar);
setSupportActionBar(toolbar);
mDrawerLayout = (DrawerLayout)findViewById(R.id.my_drawer_layout);
mDrawerList = (ListView)findViewById(R.id.left_drawer);
mDrawerLayout.setStatusBarBackgroundColor(
getResources().getColor(R.color.appPrimaryColourDark));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
{
LinearLayout linearLayout =
(LinearLayout)findViewById(R.id.linearLayout);
linearLayout.setElevation(30);
}
Aşağıda birekran görüntüsünavigasyon çekmeceyi üst yarı şeffaf olmadığını göstermek için
CEVAP
Durum çubuğu arka planı beyaz, çekmece LinearLayout arka plan. Neden? Ayarları fitsSystemWindows="" DrawerLayout ve içindeki LinearLayout için. gerçek Bu LinearLayout durum çubuğunu şeffaf olan) arkasında genişletmek için neden olur. Böylece, çekmece için arka plan, durum çubuğunda beyaz parçası yapmak.
Eğer çekmece durum çubuğunun arkasında uzatmak için (tüm durum çubuğu yarı şeffaf bir arka plan olmasını) istiyor musun diye, iki şey yapabilirsiniz:
1) sadece LinearLayout ve içindeki içerik arka plan rengi herhangi bir arka plan değeri kaldırabilirsiniz. Ya
2) LinearLayout fitsSystemWindows="true"
kaldırabilirsiniz. Bu daha mantıklı ve daha temiz bir yaklaşım olduğunu düşünüyorum. Ayrıca navigasyon çekmece uzatmak istemeyeceği bir gölge altında durum çubuğunu dökme olmaktan kaçının.
Eğer istediğiniz çekmeceni uzatmak arkasındaki durum çubuğu ve bir yarı-şeffaf durum çubuğu boyutlu kaplama, kullanabilirsiniz ScrimInsetFrameLayout gibi bir konteyner için çekmeceni içerik (Liste Görünümü) ve set durum çubuğu arkaplanı kullanarak app:insetForeground="#4000"
. Tabii ki, istediğiniz herhangi bir şey için #4000
değiştirebilirsiniz. fitsSystemWindows="true"
burada! takip etmeyi unutmayın
Ya da eğer içeriği kaplaması ve sadece düz renk görüntülemesini istiyorsanız Eğer, istediğiniz herhangi bir şey için LinearLayout arka plan ayarlayabilirsiniz. İçerik ve arka plan ayrı ayrı olsa! ayarlamak için unutma
7 | Navigasyon bar / buttons durum çub...
Navigasyon Çekmece: her tablet üzerind...
Visual Studio 2013 Güncelleştirme 2 - ...
Olamaz iOS7 gizle durum çubuğu...
WPF Drawstring değil ile bağlama'...