当前位置: 首页 > news >正文

全媒体运营师证书怎么考单页网站seo如何优化

全媒体运营师证书怎么考,单页网站seo如何优化,东莞今天特大新闻,网站建设服务哪里便宜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:android="http://schemas.android.com/apk/res/android"xmlns:systemui="http://schemas.android.com/apk/res-auto"android:layout_height="match_parent"android:layout_width="match_parent"android:background="@drawable/system_bar_background"><com.android.systemui.statusbar.phone.NavigationBarInflaterViewandroid:id="@+id/navigation_inflater"android:layout_width="match_parent"android:layout_height="match_parent" />
</com.android.systemui.statusbar.phone.NavigationBarView>

进入NavigationBarView初始化:

创建了大量按键的按键矢量图对象,和按键调度对象。

public class NavigationBarView extends FrameLayout implements PluginListener<NavGesture> {private final SparseArray<ButtonDispatcher> 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共有0,90,180,270四个角度的背景,横竖两种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 volumeAddButton=mNavigationBarView.getVolumeAddButton();ButtonDispatcher volumeSubButton=mNavigationBarView.getVolumeSubButton();// prop中为trueboolean isShowVolumeButton="true".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);}

初始化流程的错误追踪。

在底部导航栏的初始化中,刚开始加载的配置是back;home ;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:android="http://schemas.android.com/apk/res/android"xmlns:systemui="http://schemas.android.com/apk/res-auto"android:layout_width="match_parent"android:layout_height="match_parent"><FrameLayoutandroid:id="@+id/nav_buttons"android:layout_width="match_parent"android:layout_height="match_parent"><LinearLayoutandroid:id="@+id/ends_group"android:layout_width="match_parent"android:layout_height="match_parent"android:orientation="horizontal"android:clipChildren="false" /><LinearLayoutandroid:id="@+id/center_group"android:layout_width="match_parent"android:layout_height="match_parent"android:gravity="center"android:orientation="horizontal"android:clipChildren="false" /></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.shuangfujiaoyu.com/news/34441.html

相关文章:

  • 怎么查一个网站是谁做的seo难不难
  • 上海跨境电商公司深圳seo优化排名公司
  • 库存网站建设公司全国疫情高峰感染高峰进度
  • 免费网站模板库线上推广策划方案
  • 金诚财富网站是谁做的郑州网络营销公司有哪些
  • 海阔天空网站建设凡科网
  • 温州做网站哪家好windows优化大师如何卸载
  • 许昌做网站联系电话百度指数分析
  • 网站引导页怎么做国内军事新闻最新消息
  • 企业网站建设的一般要素主要包括网站的广告资源发布平台
  • 做彩票网站能挣到钱吗seo技术是干什么的
  • 个人网站备案多少钱电脑优化大师下载安装
  • 黔东网站建设深圳网站seo优化
  • 龙岩网站设计价格广州网络推广万企在线
  • 长沙网站建设推荐seo是免费的吗
  • 西安网站的设计说明网络服务合同纠纷
  • 装修网站大全简阳seo排名优化课程
  • 专业制作网站有哪些链接购买平台
  • 聊城公司做网站新东方一对一辅导价格
  • 网站开发海口北京全网营销推广
  • 山西省政府网站建设的公司百度seo怎么样优化
  • 杭州包装网站建设方案百度热搜关键词
  • 英语网站建设费用服务营销理论
  • 优化网站排名提高下列哪些店铺适合交换友情链接
  • 南京疫情最新通报seo排名规则
  • 梅州做网站百度热议
  • 山东建设住建厅网站快速排名方案
  • 哪一个做网站模版好用的抖音seo排名软件
  • 怎么做网络销售的网站企业建站公司
  • 班级做网站人的叫什么广告优化师工资一般多少