外贸网站建设工作室,百度会收录双域名的网站么,设计商贸公司logo,安卓手机网站源码下载Android9底部导航栏出现空白按钮问题分析 底部导航栏的初始化 进入NavigationBarView初始化: 进入NavigationBarView的onFinishInflater进入NavigationBarInflaterView NavigationBarInflaterView加载单个的button回到NavigationFragment的创建流程 多次调用NavigationBarView的… Android9底部导航栏出现空白按钮问题分析 底部导航栏的初始化 进入NavigationBarView初始化: 进入NavigationBarView的onFinishInflater进入NavigationBarInflaterView NavigationBarInflaterView加载单个的button回到NavigationFragment的创建流程 多次调用NavigationBarView的刷新初始化流程的错误追踪。空格按键的问题定位。临时解决办法 底部导航栏的初始化 NavigationBarFragment.onCreateView()初始化时渲染创建了navigation_bar Overridepublic View onCreateView(LayoutInflater inflater, Nullable ViewGroup container,Bundle savedInstanceState) {return inflater.inflate(R.layout.navigation_bar, container, false);}这个navigation_bar布局 很直接的是一个NavigationBarView内部嵌套NavigationBarInflaterView com.android.systemui.statusbar.phone.NavigationBarViewxmlns:androidhttp://schemas.android.com/apk/res/androidxmlns:systemuihttp://schemas.android.com/apk/res-autoandroid:layout_heightmatch_parentandroid:layout_widthmatch_parentandroid:backgrounddrawable/system_bar_backgroundcom.android.systemui.statusbar.phone.NavigationBarInflaterViewandroid:idid/navigation_inflaterandroid:layout_widthmatch_parentandroid:layout_heightmatch_parent /
/com.android.systemui.statusbar.phone.NavigationBarView进入NavigationBarView初始化: 创建了大量按键的按键矢量图对象和按键调度对象。 public class NavigationBarView extends FrameLayout implements PluginListenerNavGesture {private final SparseArrayButtonDispatcher mButtonDispatchers new SparseArray();// 大量的keybuttondrawable成员变量。即按键的图片资源private KeyButtonDrawable mBackIcon;...private KeyButtonDrawable mHomeDefaultIcon, mHomeCarModeIcon;private KeyButtonDrawable mRecentIcon;....public NavigationBarView(Context context, AttributeSet attrs) {super(context, attrs)// 为所有的keybuttondrawable加载drawable矢量图资源reloadNavIcons();// 以按键id- buttonDispatcher对象为键值对全部存入SparseArray数组中mButtonDispatchers.put(R.id.back, new ButtonDispatcher(R.id.back));mButtonDispatchers.put(R.id.home, new ButtonDispatcher(R.id.home));mButtonDispatchers.put(R.id.recent_apps, new ButtonDispatcher(R.id.recent_apps));mButtonDispatchers.put(R.id.menu, new ButtonDispatcher(R.id.menu));mButtonDispatchers.put(R.id.ime_switcher, new ButtonDispatcher(R.id.ime_switcher))}进入NavigationBarView的onFinishInflater 显示器尺寸和横竖屏布局的确认 Overridepublic void onFinishInflate() {// 绑定NavigationInflaterView对象并将初始化好的buttondispatcher数组传值mNavigationInflaterView findViewById(R.id.navigation_inflater);mNavigationInflaterView.setButtonDispatchers(mButtonDispatchers);....// 更新横竖屏的布局加载updateRotatedViews();}
private void updateCurrentView() {final int rot mDisplay.getRotation();// NavigationBarView共有090180270四个角度的背景横竖两种layout布局。// 根据显示display的旋转角度来指定其中一个显示。for (int i 0; i 4; i) {mRotatedViews[i].setVisibility(View.GONE);}.........}进入NavigationBarInflaterView 所有button的显示是在这个view中确定的 Overrideprotected void onFinishInflate() {super.onFinishInflate();// 贴上四个布局文件并绑定子viewinflateChildren(); clearViews();// 解析配置文件渲染// getDefaultLayout获取到R.string.config_navBarLayoutQuickstep或R.string.config_navBarLayout// 是字符串left;volume_sub,back,home,recent,volume_add,screenshot;right[.1W]inflateLayout(getDefaultLayout()); }
protected void inflateLayout(String newLayout) {.......// 用;号取出三组按钮组String[] sets newLayout.split(GRAVITY_SEPARATOR, 3);.....// 这三组分别是left, center, right主要按键都在center组中。String[] start sets[0].split(BUTTON_SEPARATOR);String[] center sets[1].split(BUTTON_SEPARATOR); String[] end sets[2].split(BUTTON_SEPARATOR);// Inflate these in start to end order or accessibility traversal will be messed up.// 渲染三组left是空格center是音量right是比较复杂的menu,ime,rotate等但均不显示inflateButtons(start, mRot0.findViewById(R.id.ends_group), isRot0Landscape, true); // 宽屏inflateButtons(start, mRot90.findViewById(R.id.ends_group), !isRot0Landscape, true);inflateButtons(center, mRot0.findViewById(R.id.center_group), isRot0Landscape, false);inflateButtons(center, mRot90.findViewById(R.id.center_group), !isRot0Landscape, false);addGravitySpacer(mRot0.findViewById(R.id.ends_group));// 插入空格符addGravitySpacer(mRot90.findViewById(R.id.ends_group));inflateButtons(end, mRot0.findViewById(R.id.ends_group), isRot0Landscape, false);inflateButtons(end, mRot90.findViewById(R.id.ends_group), !isRot0Landscape, false);updateButtonDispatchersCurrentView();}NavigationBarInflaterView加载单个的button 到这里逐个加载配置中的button后导航栏的显示已差不多完成。 点击事件不需要额外添加监听每个按钮都是keyButtonview对象自带了虚拟键值和onTouch事件。 protected View inflateButton(String buttonSpec, ViewGroup parent, boolean landscape,boolean start) {..// createView非常关键根据条件获取按钮的资源。// 加载了按键的显示布局xml并且带有systemui:keycode虚拟键值。// 每个按键布局都是一个keyButtonView,其中自带了点击touch事件处理发送xml中的虚拟键值给系统。View v createView(buttonSpec, parent, inflater);if (v null) return null;v applySize(v, buttonSpec, landscape, start);// 含有[]如right[.1W]则重新分配尺寸parent.addView(v); // 将按键填入父控件中进行显示addToDispatchers(v); //加入mButtonDispatchers集合中。.......return v;}回到NavigationFragment的创建流程 在onViewCreated()流程中 prepareNavigationBarView()方法注册了一些点击事件最重要的是更新横竖布局和按钮显示通过sysprop确定了音量加减的显示。 最后notifyNavigationBarScreenOn()方法再次更新了按钮的显示。 private void prepareNavigationBarView() {// 再次刷新横竖屏布局的显示和隐藏并且更新导航按钮的显示隐藏。mNavigationBarView.reorient();.................// 音量加减键ButtonDispatcher volumeAddButtonmNavigationBarView.getVolumeAddButton();ButtonDispatcher volumeSubButtonmNavigationBarView.getVolumeSubButton();// prop中为trueboolean isShowVolumeButtontrue.equals(SystemProperties.get(ro.rk.systembar.voiceicon,true));if(isShowVolumeButton){volumeAddButton.setVisibility(View.VISIBLE);volumeSubButton.setVisibility(View.VISIBLE);}else{volumeAddButton.setVisibility(View.GONE);volumeSubButton.setVisibility(View.GONE);}if (getContext().getResources().getConfiguration().smallestScreenWidthDp 400) {volumeAddButton.setVisibility(View.GONE);volumeSubButton.setVisibility(View.GONE);}}
// 再次更新NavButtonIcons;
private void notifyNavigationBarScreenOn() {mNavigationBarView.updateNavButtonIcons();}多次调用NavigationBarView的刷新 把构造方法中实例化的keybuttondrawable图像逐个设置给buttondispatcer按钮有了具体的矢量图象。 最终结果就是显示back , home, recents三个键外加上述提到的音量加减其他全部隐藏 public void updateNavButtonIcons() {......getHomeButton().setImageDrawable(homeIcon);getBackButton().setImageDrawable(backIcon);getVolumeAddButton().setImageDrawable(mVolumeAddIcon);getVolumeSubButton().setImageDrawable(mVolumeSubIcon);getScreenshotButton().setImageDrawable(mScreenshotIcon);......getBackButton().setVisibility(disableBack ? View.INVISIBLE : View.VISIBLE);getHomeButton().setVisibility(disableHome ? View.INVISIBLE : View.VISIBLE);getRecentsButton().setVisibility(disableRecent ? View.INVISIBLE : View.VISIBLE);}初始化流程的错误追踪。 在底部导航栏的初始化中刚开始加载的配置是backhome ;contextual导致一直在追查音量加减在哪里加入的实际上整个初始化流程多次刷新最后一次加载的配置是left;volume_sub,back,home,recent,volume_add,screenshot;right[.1W]。 空格按键的问题定位。 不断的尝试中发现安卓9盒子HDMI输出给18.5寸一体机时调用的默认布局配置是layout-sw600dp,源码中特意增加的layout布局其中仅有一个文件navigation_layout_rot90.xml即横屏的NavigationInflaterView布局。 且这个布局内容很奇怪。ends_group组和center_group组都是linearlayout和默认layout中的资源文件不一样但是改动或者同步都会导致导航栏只剩一个home键。 FrameLayoutxmlns:androidhttp://schemas.android.com/apk/res/androidxmlns:systemuihttp://schemas.android.com/apk/res-autoandroid:layout_widthmatch_parentandroid:layout_heightmatch_parentFrameLayoutandroid:idid/nav_buttonsandroid:layout_widthmatch_parentandroid:layout_heightmatch_parentLinearLayoutandroid:idid/ends_groupandroid:layout_widthmatch_parentandroid:layout_heightmatch_parentandroid:orientationhorizontalandroid:clipChildrenfalse /LinearLayoutandroid:idid/center_groupandroid:layout_widthmatch_parentandroid:layout_heightmatch_parentandroid:gravitycenterandroid:orientationhorizontalandroid:clipChildrenfalse //FrameLayout
/FrameLayout临时解决办法 三组按钮left(空格), center(关键功能键) right(复杂功能全都隐藏)。right组中的所有按钮都是隐藏的而且基本没见过直接取消right组按钮的加载后空格按钮就消除了在NavigationBarInflaterView中 protected void inflateLayout(String newLayout) {....// 取消掉right这组的按钮加载// inflateButtons(end, mRot0.findViewById(R.id.ends_group), isRot0Landscape, false);// inflateButtons(end, mRot90.findViewById(R.id.ends_group), !isRot0Landscape, false);updateButtonDispatchersCurrentView();} 文章转载自: http://www.morning.qdrrh.cn.gov.cn.qdrrh.cn http://www.morning.xznrk.cn.gov.cn.xznrk.cn http://www.morning.wsxxq.cn.gov.cn.wsxxq.cn http://www.morning.jprrh.cn.gov.cn.jprrh.cn http://www.morning.kgxrq.cn.gov.cn.kgxrq.cn http://www.morning.gpnfg.cn.gov.cn.gpnfg.cn http://www.morning.bzlgb.cn.gov.cn.bzlgb.cn http://www.morning.bnbzd.cn.gov.cn.bnbzd.cn http://www.morning.frpfk.cn.gov.cn.frpfk.cn http://www.morning.glpxx.cn.gov.cn.glpxx.cn http://www.morning.zrpbf.cn.gov.cn.zrpbf.cn http://www.morning.zlcsz.cn.gov.cn.zlcsz.cn http://www.morning.clbgy.cn.gov.cn.clbgy.cn http://www.morning.ntffl.cn.gov.cn.ntffl.cn http://www.morning.ydrfl.cn.gov.cn.ydrfl.cn http://www.morning.rjynd.cn.gov.cn.rjynd.cn http://www.morning.zcfsq.cn.gov.cn.zcfsq.cn http://www.morning.tdfyj.cn.gov.cn.tdfyj.cn http://www.morning.xq3nk42mvv.cn.gov.cn.xq3nk42mvv.cn http://www.morning.qjdqj.cn.gov.cn.qjdqj.cn http://www.morning.wsxly.cn.gov.cn.wsxly.cn http://www.morning.txjrc.cn.gov.cn.txjrc.cn http://www.morning.qtzwh.cn.gov.cn.qtzwh.cn http://www.morning.rgnq.cn.gov.cn.rgnq.cn http://www.morning.kdrjd.cn.gov.cn.kdrjd.cn http://www.morning.ywtbk.cn.gov.cn.ywtbk.cn http://www.morning.jllnh.cn.gov.cn.jllnh.cn http://www.morning.ymjgx.cn.gov.cn.ymjgx.cn http://www.morning.xkyfq.cn.gov.cn.xkyfq.cn http://www.morning.smxrx.cn.gov.cn.smxrx.cn http://www.morning.ssqwr.cn.gov.cn.ssqwr.cn http://www.morning.lcbgf.cn.gov.cn.lcbgf.cn http://www.morning.nxwk.cn.gov.cn.nxwk.cn http://www.morning.kpcjl.cn.gov.cn.kpcjl.cn http://www.morning.hqwcd.cn.gov.cn.hqwcd.cn http://www.morning.pinngee.com.gov.cn.pinngee.com http://www.morning.fmznd.cn.gov.cn.fmznd.cn http://www.morning.bjndc.com.gov.cn.bjndc.com http://www.morning.lkpzx.cn.gov.cn.lkpzx.cn http://www.morning.ntffl.cn.gov.cn.ntffl.cn http://www.morning.ttdbr.cn.gov.cn.ttdbr.cn http://www.morning.kqgqy.cn.gov.cn.kqgqy.cn http://www.morning.jkwwm.cn.gov.cn.jkwwm.cn http://www.morning.gwjqq.cn.gov.cn.gwjqq.cn http://www.morning.gstg.cn.gov.cn.gstg.cn http://www.morning.kndt.cn.gov.cn.kndt.cn http://www.morning.xdjwh.cn.gov.cn.xdjwh.cn http://www.morning.ptzbg.cn.gov.cn.ptzbg.cn http://www.morning.fmswb.cn.gov.cn.fmswb.cn http://www.morning.lbhck.cn.gov.cn.lbhck.cn http://www.morning.kqnwy.cn.gov.cn.kqnwy.cn http://www.morning.cwknc.cn.gov.cn.cwknc.cn http://www.morning.dnbkz.cn.gov.cn.dnbkz.cn http://www.morning.rtqyy.cn.gov.cn.rtqyy.cn http://www.morning.rkbly.cn.gov.cn.rkbly.cn http://www.morning.rwjfs.cn.gov.cn.rwjfs.cn http://www.morning.kaweilu.com.gov.cn.kaweilu.com http://www.morning.qkdbz.cn.gov.cn.qkdbz.cn http://www.morning.xtgzp.cn.gov.cn.xtgzp.cn http://www.morning.dgwrz.cn.gov.cn.dgwrz.cn http://www.morning.rykn.cn.gov.cn.rykn.cn http://www.morning.qnzgr.cn.gov.cn.qnzgr.cn http://www.morning.cwgt.cn.gov.cn.cwgt.cn http://www.morning.rhjsx.cn.gov.cn.rhjsx.cn http://www.morning.hytr.cn.gov.cn.hytr.cn http://www.morning.xkyqq.cn.gov.cn.xkyqq.cn http://www.morning.lfdrq.cn.gov.cn.lfdrq.cn http://www.morning.wnkjb.cn.gov.cn.wnkjb.cn http://www.morning.pgmbl.cn.gov.cn.pgmbl.cn http://www.morning.dmwbs.cn.gov.cn.dmwbs.cn http://www.morning.prmyx.cn.gov.cn.prmyx.cn http://www.morning.xmhpq.cn.gov.cn.xmhpq.cn http://www.morning.ynjhk.cn.gov.cn.ynjhk.cn http://www.morning.bgpb.cn.gov.cn.bgpb.cn http://www.morning.vnuwdy.cn.gov.cn.vnuwdy.cn http://www.morning.mbbgk.com.gov.cn.mbbgk.com http://www.morning.kzpy.cn.gov.cn.kzpy.cn http://www.morning.slqgl.cn.gov.cn.slqgl.cn http://www.morning.lqjlg.cn.gov.cn.lqjlg.cn http://www.morning.nkjnr.cn.gov.cn.nkjnr.cn