今天学习了一篇非常不错的关于Android状态栏着色的文章,文章见http://www.jianshu.com/p/bae25b5eb867。
这篇文章为我们提供了三种状态栏着色的方法,这里我就不详细说了,看文章就好。
但我这里想要记录一下的不只是关于状态栏着色的问题,而是这篇文章demo中用到了的Android6.x的新控件NavigationView与DrawerLayout以及Toolbar的配套使用,达到非常不错的导航栏效果,并且使用起来也是非常的简单易用。代码示例如下:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorPrimary"
android:paddingTop="@dimen/padding_top"
android:theme="@style/AppTheme.AppBarOverlay" />
<ListView
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
<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:headerLayout="@layout/nav_head_main"
app:menu="@menu/menu_drawer" />
</android.support.v4.widget.DrawerLayout>
demo地址见:https://github.com/love-311/StatusBarColor,感兴趣的可以自行下载研究一下。