1 本周目标
- resetful tabtop dataitem
2
2.1 Adapter-1
1.sparsearray比arraylist linkedlist 查找效率高得多
2.2 Adapter-2
4
4.6 用户体验优化—沉浸式状态栏
1.目的是使得状态栏 内容区域融为一体
2.将内容区域延展到状态栏之下
3.适配5.0以上系统,5.0以上用户占比超过87%
4.
object HiStatusBar {
/**
* darkContent true 白底黑字,false 黑底白字
* statusBarColor 状态栏背景色
* translucent 沉浸式效果 页面布局延伸到状态栏下
*/
fun setStatusBar(
activity: Activity,
darkContent: Boolean,
statusBarColor: Int = Color.WHITE,
translucent: Boolean
) {
val window = activity.window
val decorView = window.decorView
var visibility = decorView.systemUiVisibility
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
//多个平台 版本 生效
//请求系统绘制状态栏背景色
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS)
//这两个不能同时出现
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS)
window.statusBarColor = statusBarColor
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
visibility = if (darkContent) {
//白底黑字--浅色主题
visibility or View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
} else {
//黑底白字--深色主题
visibility and View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR.inv()
}
}
if (translucent) {
// 启用沉浸式效果,使得页面布局延伸到状态栏之下,但状态栏图标看不见了。加上SYSTEM_UI_FLAG_LAYOUT_STABLE,状态栏图标恢复可见性
Log.e("john", "执行到这里了")
visibility =
// visibility or View.SYSTEM_UI_FLAG_FULLSCREEN or View.SYSTEM_UI_FLAG_LAYOUT_STABLE //状态栏图标看不见
visibility or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or View.SYSTEM_UI_FLAG_LAYOUT_STABLE
}
decorView.systemUiVisibility = visibility
}
}