Android 7.1 虚拟按键(NavigationBar)源码分析 控件加载、属性控制隐藏
https://blog.csdn.net/kuaiguixs/article/details/78291695 Android 7.0 虚拟按键(NavigationBar)源码分析 之 View的创建流程
一.主要的几个类
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | //实现 单个虚拟按键的 自定义ImageView frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonView.java //虚拟按键的容器,实现整个 虚拟导航条的 自定义LinearLayout frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java //动态加载虚拟按键,放入NavigationBarView frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarInflaterView.java //虚拟导航条对应的布局文件 frameworks/base/packages/SystemUI/res/layout/navigation_bar.xml //实现虚拟按键的点击效果 frameworks/base/services/core/java/com/android/server/policy/PhoneWindowManager.java |
二. inflateNavigationBarView 方法,它加载了布局 R.layout.navigation_bar,作为虚拟按键的容器 属性控制隐藏
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | --- a/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarInflaterView.java +++ b/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarInflaterView.java @@ - 32 , 6 + 32 , 7 @@ import android.widget.Space; import com.android.systemui.R; import com.android.systemui.statusbar.policy.KeyButtonView; import com.android.systemui.tuner.TunerService; + import android.os.SystemProperties; import java.util.Objects; public class NavigationBarInflaterView extends FrameLayout implements TunerService.Tunable { @@ - 265 , 45 + 266 , 59 @@ public class NavigationBarInflaterView extends FrameLayout implements TunerServi String button = extractButton(buttonSpec); View v = null ; if (HOME.equals(button)) { - v = inflater.inflate(R.layout.home, parent, false ); - if (landscape && isSw600Dp()) { - setupLandButton(v); - } + if (SystemProperties.get( "persist.navi.home" , "true" ).equals( "true" )){ + v = inflater.inflate(R.layout.home, parent, false ); + if (landscape && isSw600Dp()) { + setupLandButton(v); + } + } } else if (BACK.equals(button)) { + if (SystemProperties.get( "ro.navi.back" , "true" ).equals( "true" )){ v = inflater.inflate(R.layout.back, parent, false ); if (landscape && isSw600Dp()) { setupLandButton(v); } + } } else if (RECENT.equals(button)) { + if (SystemProperties.get( "ro.navi.recent" , "true" ).equals( "true" )){ v = inflater.inflate(R.layout.recent_apps, parent, false ); if (landscape && isSw600Dp()) { setupLandButton(v); } + } } else if (SCREENSHOT.equals(button)) { v = inflater.inflate(R.layout.screenshot, parent, false ); if (landscape && isSw600Dp()) { setupLandButton(v); } } else if (VOLUME_ADD.equals(button)) { + if (SystemProperties.get( "ro.navi.volume_add" , "true" ).equals( "true" )){ v = inflater.inflate(R.layout.volume_add, parent, false ); if (landscape && isSw600Dp()) { setupLandButton(v); } + } } else if (VOLUME_SUB.equals(button)) { + if (SystemProperties.get( "ro.navi.volume_sub" , "true" ).equals( "true" )){ v = inflater.inflate(R.layout.volume_sub, parent, false ); if (landscape && isSw600Dp()) { setupLandButton(v); } + } } else if (POWER_DOWN.equals(button)) { + if (SystemProperties.get( "ro.navi.powerdown" , "true" ).equals( "true" )){ v = inflater.inflate(R.layout.powerdown, parent, false ); if (landscape && isSw600Dp()) { setupLandButton(v); } + } } else if (HIDE_BAR.equals(button)) { + if (SystemProperties.get( "ro.navi.hide_bar" , "true" ).equals( "true" )){ v = inflater.inflate(R.layout.hide_bar, parent, false ); if (landscape && isSw600Dp()) { setupLandButton(v); } + } } else if (MENU_IME.equals(button)) { v = inflater.inflate(R.layout.menu_ime, parent, false ); } else if (NAVSPACE.equals(button)) { @@ - 321 , 6 + 336 , 9 @@ public class NavigationBarInflaterView extends FrameLayout implements TunerServi } else { return null ; } + if (v == null ){ + return null ; + } if (size != 0 ) { ViewGroup.LayoutParams params = v.getLayoutParams(); |
分类:
RockChip
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 地球OL攻略 —— 某应届生求职总结
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· 提示词工程——AI应用必不可少的技术
· .NET周刊【3月第1期 2025-03-02】