Android Studio 2.0で新しいアプリケーションを作成しました。ナビゲーションパッドをToolbar
以下にしたいと考えています。マテリアルデザインの仕様ではToolbar
より上にあるはずですが、私の引き出しにはそれほど多くのエントリがなく、Googleが提供するきちんとしたアイコンアニメーションを見たいと思っています。fitsSystemWindowsを使用しているときに灰色の境界線が表示されないNavigationView
DrawerLayout
をトップレベルCoordinatorLayout
に配置することで、私が望むものを得ることができました。
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="com.company.app.MainActivity">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.DrawerLayout
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:openDrawer="start">
<include layout="@layout/content_main" />
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
app:menu="@menu/activity_main_drawer" />
</android.support.v4.widget.DrawerLayout>
</android.support.design.widget.CoordinatorLayout>
トップレベルのレイアウトにandroid:fitsSystemWindow="true"
を使用していますので、ステータスバーに色を付けることができます。しかし、私がそうするとき、ナビゲーション引き出しは灰色の上の境界線を持っています。
私は、国境は大丈夫だろう(ツールバー上)それをGoogleがそれを指定された方法を使用することだろうが、この方法は、それだけで見苦しいです。これを取り除く方法はありますか?
私はNavigationView.onInsetsChanged(Rect rect)
を上書きして実験しましたが、上部に項目を配置できましたが、灰色の枠線は残っていました。
あなたは、ステータスバーの "着色" とはどういう意味ですか:
はあなたにこれを取得する必要?その色はあなたの 'colorPrimaryDark'から来ます – Pztar
これは本当です。しかし、 'colorPrimaryDark'の色合いを得るためには、ルート要素に対して' android:fitsSystemWindow = "true" 'を使わなければなりません。そして、これは 'NavigationView'のこの灰色の境界線を引き起こします。 – Saenic