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

加盟热线衡水seo优化

加盟热线,衡水seo优化,公司取名字参考大全免费,怎么做彩票游戏网站Android 修复在 Settings 首页,按键盘方向键逐个单选 问题现象问题分析解决办法 问题现象 在 Settings 主界面,按键盘方向键上下会直接整个选中,无法单条选中变色,而在二级页面中按方向键上下是正常的。 没有遥控器可以通过 adb…

Android 修复在 Settings 首页,按键盘方向键逐个单选

  • 问题现象
  • 问题分析
  • 解决办法

问题现象

在 Settings 主界面,按键盘方向键上下会直接整个选中,无法单条选中变色,而在二级页面中按方向键上下是正常的。

没有遥控器可以通过 adb 指令模拟下键

adb shell input keyevent 20

问题分析

Settings 中都是用的 Preference 控件来显示界面的,既然二级页面可以,主界面不行的话,那应该是主界面布局有问题。

盲猜和焦点占用有关系,找到主界面布局文件 settings_homepage_container.xml

<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayoutxmlns:android="http://schemas.android.com/apk/res/android"xmlns:app="http://schemas.android.com/apk/res-auto"android:id="@+id/settings_homepage_container"android:fitsSystemWindows="true"android:layout_width="match_parent"android:layout_height="match_parent"><androidx.core.widget.NestedScrollViewandroid:id="@+id/main_content_scrollable_container"android:layout_width="match_parent"android:layout_height="match_parent"app:layout_behavior="com.android.settings.widget.FloatingAppBarScrollingViewBehavior"> <LinearLayoutandroid:id="@+id/homepage_container"android:layout_width="match_parent"android:layout_height="wrap_content"android:orientation="vertical"><FrameLayoutandroid:id="@+id/contextual_cards_content"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginStart="@dimen/contextual_card_side_margin"android:layout_marginEnd="@dimen/contextual_card_side_margin"/><FrameLayoutandroid:id="@+id/main_content"android:layout_width="match_parent"android:layout_height="wrap_content"android:animateLayoutChanges="true"android:background="?android:attr/windowBackground"/></LinearLayout></androidx.core.widget.NestedScrollView><com.google.android.material.appbar.AppBarLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:touchscreenBlocksFocus="false"android:keyboardNavigationCluster="false"><include layout="@layout/search_bar"/></com.google.android.material.appbar.AppBarLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

可以看到主界面加载的 Preference 最终都是在 main_content 中

层级结构
NestedScrollView
LinearLayout
FrameLayout
Preference

经过验证发现,焦点被最外层 NestedScrollView 处理了,无法传递到 Preference 中,所以就无法单条选中

分析了下 PreferenceScreen 本身就具有屏幕显示不全时可滚动的机制,

谷歌在这最外面又包了一个 NestedScrollView 岂不是多此一举,其实不是这样的,是因为里面还有其它数据,

看到 contextual_cards_content 这个,是用来装 Suggestion 菜单的,为了整体能够滚动,所以套了一个 NestedScrollView

为了事件能过直接被 PreferenceScreen 捕获,

参考了这篇 https://blog.51cto.com/u_15073486/5363888 发现没啥用,而且还浪费时间。。

一开始尝试了通过事件传递回调的方式,试了好几种发现都不行(如果你能成功可以反馈给我),

后来直接将外层的 NestedScrollView 和 LinearLayout 干掉,

这样做虽然可以让主界面单条选中,但弊端是牺牲了 Suggestion 功能。

解决办法

干掉 NestedScrollView,将 homepage_container 和 contextual_cards_content 都设置成 gone,避免编译报错

<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayoutxmlns:android="http://schemas.android.com/apk/res/android"xmlns:app="http://schemas.android.com/apk/res-auto"android:id="@+id/settings_homepage_container"android:fitsSystemWindows="true"android:layout_width="match_parent"android:layout_height="match_parent"><!--     <androidx.core.widget.NestedScrollViewandroid:id="@+id/main_content_scrollable_container"android:layout_width="match_parent"android:layout_height="match_parent"app:layout_behavior="com.android.settings.widget.FloatingAppBarScrollingViewBehavior"> --><LinearLayoutandroid:visibility="gone"android:id="@+id/homepage_container"android:layout_width="match_parent"android:layout_height="wrap_content"android:orientation="vertical"/><FrameLayoutandroid:visibility="gone"android:id="@+id/contextual_cards_content"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginStart="@dimen/contextual_card_side_margin"android:layout_marginEnd="@dimen/contextual_card_side_margin"/><FrameLayoutandroid:id="@+id/main_content"android:layout_width="match_parent"android:layout_height="wrap_content"android:animateLayoutChanges="true"android:background="?android:attr/windowBackground"/><!--  </LinearLayout></androidx.core.widget.NestedScrollView> --><com.google.android.material.appbar.AppBarLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:touchscreenBlocksFocus="false"android:keyboardNavigationCluster="false"><include layout="@layout/search_bar"/></com.google.android.material.appbar.AppBarLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
http://www.15wanjia.com/news/35932.html

相关文章:

  • 石碣做网站优化seo服务指什么意思
  • 做教育机器网站百度大搜
  • 武汉响应式网站制作成都网站seo厂家
  • 百度云服务器做php网站网店推广的重要性
  • 网站自助建设推广超级外链吧
  • 河北邯郸做移动网站seo辅助工具
  • 南阳做网站优化哪家好seo推广主要做什么
  • 申请wordpress厦门谷歌seo公司有哪些
  • 做消费金融网站汕头seo快速排名
  • 镇江建筑公司排名最新关键词优化排名怎么做
  • 外网建筑设计网站一键生成app制作器
  • seo关键词优化方案正规seo排名外包
  • 做相同网站违法吗网站建设制作模板
  • 网站个免费的空间网站收录
  • 基金网站制作网站推广策划
  • 宁波地区做网络推广的seo整站优化服务
  • 企业网站建设cms站为什么外包会是简历污点
  • 动态网站站内搜索本地推广平台有哪些
  • 云南做网站公司电商网站销售数据分析
  • wordpress返回按钮南宁seo推广优化
  • 广州网站设计公司兴田德润电话多少软文是什么意思通俗点
  • 内网做测试 网站微信授权登录软文广告投放平台
  • 什么网站可以找人做软件下载如何销售自己产品方法有哪些
  • wordpress做新闻网站的主题汕头seo不错
  • 峰峰专业做网站新闻头条今日要闻国内新闻最新
  • 只做一页的网站多少钱semaphore
  • 网站改版做301重定向公司网站制作
  • 免费建网站平台哪个好seo什么意思简单来说
  • 成都科技网站建设哪里有外贸出口平台网站
  • 做手表网站用什么源码比较好深圳网络推广培训机构