如果对于android SystemUI还不够了解,
请查阅我的android SystemUI全解析
此处默认大家对于SysytemUI有足够的认知
如果想对系统NavigationBar做出改变(视需求而定)
此处我将介绍几种改变NavigationBar的方法
一、改变大小(高度)
通过
frameworks/base/policy/src/com/android/internal/policy/impl/PhoneWindowManager.j
ava
ava
public void setInitialDisplaySize(Display display, int width, int height, int density) {
.......}
通过这个函数setInitialDisplaySize(Display display, int width, int height, int density),
我们可以发现android手机或者平板Display=FULLSCREEN-NavigationBar-StatusBar
// Width of the navigation bar when presented vertically along one side
mNavigationBarWidthForRotation[mPortraitRotation] =
mNavigationBarWidthForRotation[mUpsideDownRotation] =
mNavigationBarWidthForRotation[mLandscapeRotation] =
mNavigationBarWidthForRotation[mSeascapeRotation] =
mContext.getResources().getDimensionPixelSize(
com.android.internal.R.dimen.navigation_bar_width);
// SystemUI (status bar) layout policy
int shortSizeDp = shortSize * DisplayMetrics.DENSITY_DEFAULT / density;
这里我们不难发现NavigationBarWidth取决于com.android.internal.R.dimen.navigation_bar_width
那么我们改变frameworks\base\core\res\res\values\dimens.xml
<!-- Height of the status bar
-->
<dimen name="status_bar_height">25dip</dimen>
- <!-- Height of the bottom navigation / system bar.
-->
<dimen name="navigation_bar_height">48dp</dimen>
- <!-- Height of the bottom navigation bar in portrait; often the same as @dimen/navigation_bar_height
-->
<dimen name="navigation_bar_height_landscape">48dp</dimen>
- <!-- Width of the navigation bar when it is placed vertically on the screen
-->
<dimen name="navigation_bar_width">42dp</dimen>
- <!-- Height of notification icons in the status bar
-->
<dimen name="status_bar_icon_size">24dip</dimen>
改变值为
<dimen name="navigation_bar_width">300dp</dimen>
编译焼铸开机后 将会发现我们的手机或者平板将会出现巨大的惊喜
同理,如果我们将高度设为0,则可想而知出现的会是什么样子(不建议这样改动)
此时,如果我们不仅仅是单纯的想要改动NavigationBar的大小
比如,我们想要改动它的外观,此时我们应该怎么办呢
我们知道mNavigationBar已经创建(mNavigationBarView =
(NavigationBarView) View.inflate(context, R.layout.navigation_bar, null);)
根据布局我们可以知道NavigationBar的样式(这里我们不贴出系统xml文件)
我们知悉NavigationBar源码位置
\frameworks\base\packages\SystemUI\src\com\android\systemui\statusbar\phone\NavigationBarView
相应的布局文件\frameworks\base\packages\SystemUI\res\layout\navigation_bar.xml
此时 如果我们隐藏系统NavigationBar.xml里面的控件,并将其改成自己的控件