Android 沉浸式(一)
来源:互联网 发布:淘宝小蜜是小二吗 编辑:程序博客网 时间:2024/06/06 08:48
一、首先写个ActionBar布局。
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="50dp" android:gravity="center_vertical" android:orientation="horizontal"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="首页" /></LinearLayout>
二、在style.xml里面添加一些的style
<resources xmlns:tools="http://schemas.android.com/tools"> <style name="AppTheme" parent="@style/Theme.AppCompat.Light"> <item name="actionBarStyle">@style/ActionBar.Solid.Custom</item> <item name="actionBarSize">48dp</item> <item name="android:windowTranslucentStatus" tools:targetApi="kitkat">true</item> <item name="android:windowContentOverlay">@null</item> </style> <style name="ActionBar.Solid.Custom" parent="@style/Widget.AppCompat.Light.ActionBar.Solid"> <item name="background">@color/actionBar</item> <item name="titleTextStyle">@style/MyActionBarTitleText</item> </style> <style name="MyActionBarTitleText" parent="@style/TextAppearance.AppCompat.Widget.ActionBar.Title"> <item name="android:textColor">@android:color/white</item> </style></resources>
三、定义颜色值
<color name="actionBar">#00000000</color>
四、Activity代码
ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setDisplayShowCustomEnabled(true); actionBar.setCustomView(R.layout.action_bar_layout); Toolbar parent = (Toolbar) actionBar.getCustomView().getParent(); parent.setContentInsetsAbsolute(0, 0); } getSupportActionBar().setElevation(0);
五、需注意
在mainActivity根布局里面添加 android:fitsSystemWindows=”true”这个属性。android:fitsSystemWindows=”true”,这个属性表示系统UI(状态栏、导航栏)可见的时候,会给我们的布局加上padding(paddingTop、paddingBottom)属性,这样内容就不会被盖住了。
1 0
- Android 沉浸式(一)
- Android沉浸式状态栏(一)
- android沉浸式状态栏--解决方案(一)
- Android沉浸式状态栏(一)
- Android沉浸式(侵入式)标题栏(状态栏)Status(一)
- Android沉浸式(侵入式)标题栏(状态栏)Status(一)
- Android一体式(沉浸式)状态栏的实现
- Android 沉浸式状态栏实现攻略(一)
- 沉浸式状态栏(一)
- 沉浸式状态栏(一)
- Android 沉浸式状态栏 实现方式一
- Android 沉浸式 完全沉浸
- Android实战基础(一)超简单的实现沉浸式状态栏
- Android 沉浸式状态栏 一设置状态栏颜色
- Android状态栏透明(沉浸式效果)
- Android沉浸式状态栏(二)
- android沉浸式应用(模式)
- Android 实现沉浸式(Translucent Bars)
- Promise初体验
- strncmp
- BRISK算法
- android6 要素2,应用链接
- 微信读书 iOS 性能优化总结
- Android 沉浸式(一)
- windows文件关联、打开方式列表之修改注册表攻略
- Android Error:Execution failed for task ':charts:clean'. > Unable to delete directory:
- Shell until循环
- Android 图片SD卡缓存 使用简单 支持预取 支持多种缓存算法 支持不同网络类型 支持序列化 (八)
- java基础01
- 七.Android的Activity生命周期和启动模式
- LeetCode 105. Construct Binary Tree from Preorder and Inorder Traversal
- [ceph]初探之安装和部署