沉浸式状态栏效果的简单实现
来源:互联网 发布:淘宝买家怎么申诉违规 编辑:程序博客网 时间:2024/06/03 13:22
一:设置AndroidManifest.xml 的AppTheme 的Parenet为NoActionBar (windows用户在文件选中AppTheme 然后ctrl+B快速跳转)
<application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme">
<!-- Base application theme. --> <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> <!-- Customize your theme here. --> <item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorAccent">@color/colorAccent</item>
二:在平常布局中实现效果如下:
实现步骤:就是俩个界面,俩个Activity,布局很简单 按钮的布局就不贴了。
在有ImageView的Activi中创造方法,并在onCreate里面调用
/** * 沉浸式状态栏 */ private void initState() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { //透明状态栏 getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); //透明导航栏 getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); } }
第二个布局的文件:(一定要添加 android:fitsSystemWindows="true")
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <!--这里可以自定义Toolbar--> <ImageView android:layout_width="match_parent" android:layout_height="200dp" android:src="@drawable/bg" android:scaleType="centerCrop" android:fitsSystemWindows="true" /></LinearLayout>
三:在DrawerLayout中也能实现此效果 (效果还是很明显的0.0)
实现方法和上面也是一样的。
最后,Fragment暂时还没用到,用到在体验。
参考:http://www.jianshu.com/p/be2b7be418d7
阅读全文
0 0
- 沉浸式状态栏效果的简单实现
- Android沉浸式状态栏的简单实现
- Android沉浸式状态栏的简单实现
- Android 沉浸式状态栏的简单实现
- 简单实现沉浸式状态栏
- 沉浸式状态栏(修改状态栏)颜色的简单实现
- android 4.4以上可以实现的沉浸式状态栏效果
- android实现沉浸式状态栏效果
- 沉浸式状态栏的实现;
- 沉浸式状态栏的实现
- 沉浸式状态栏的实现
- 沉浸式状态栏的实现
- 沉浸式状态栏的实现
- 沉浸式状态栏的实现
- 沉浸式状态栏的实现
- 沉浸式状态栏的实现
- android沉浸式状态栏的最简单实现
- android沉浸式状态栏的最简单实现
- MQTT
- libiec61850系列(一):编译
- Base64编码/解码模块
- Java编程命名规范
- dialog 被另外一个dialog覆盖,生命周期如何执行
- 沉浸式状态栏效果的简单实现
- 解决复制虚拟机无法识别网卡的问题
- matlab r2016a最新安装激活教程|破解教程
- AliIM2017_taobao(9.09.05C)
- 使用winpcap 发送IGMP包
- 序列化与反序列化工具类
- Python3.0+学习记录-编程第一步
- Aspose.Words导出主从表格
- sql 存储过程 游标 事务