- 4.4 模拟器
- 5.x 真机
[new]贴个如果顶部是图片的效果图,其实是一样的,为了方便我就放侧栏的顶部了。
稍等,csdn图片服务器异常…
ok,有了效果图之后就开始看实现了。
三、实现半透明状态栏
因为本例使用了NavigationView,所以布局代码稍多,当然如果你不需要,可以自己进行筛减。
注意引入相关依赖:
compile ‘com.android.support:appcompat-v7:22.2.1’
compile ‘com.android.support:support-v4:22.2.1’
compile ‘com.android.support:design:22.2.0’
(一)colors.xml 和 styles.xml
首先我们定义几个颜色:
res/values/color.xml
<?xml version="1.0" encoding="utf-8"?>#FF03A9F4
#FF0288D1
@color/primary_dark
下面定义几个styles.xml
注意文件夹的路径:
values/styles.xml
values-v19
ok,这个没撒说的。注意我们的主题是基于NoActionBar的,android:windowTranslucentStatus
这个属性是v19开始引入的。
(二)布局文件
activity_main.xml
<android.support.v4.widget.DrawerLayout
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”
<LinearLayout
android:id=“@+id/id_main_content”
android:layout_width=“match_parent”
android:layout_height=“match_parent”
android:orientation=“ver