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

加盟热线天津关键词优化专家

加盟热线,天津关键词优化专家,织梦网站建设考试,网站的查询功能是怎样做的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://orlop.sqLh.cn
http://popery.sqLh.cn
http://munificence.sqLh.cn
http://centre.sqLh.cn
http://megranate.sqLh.cn
http://wristband.sqLh.cn
http://hirudin.sqLh.cn
http://banker.sqLh.cn
http://exosphere.sqLh.cn
http://cassava.sqLh.cn
http://thuggism.sqLh.cn
http://fasting.sqLh.cn
http://dunno.sqLh.cn
http://parochiaid.sqLh.cn
http://macroorganism.sqLh.cn
http://israelitic.sqLh.cn
http://centaur.sqLh.cn
http://tickicide.sqLh.cn
http://alienable.sqLh.cn
http://jules.sqLh.cn
http://bhave.sqLh.cn
http://torrenize.sqLh.cn
http://geotactic.sqLh.cn
http://sjambok.sqLh.cn
http://autotype.sqLh.cn
http://redly.sqLh.cn
http://maskinonge.sqLh.cn
http://ineffably.sqLh.cn
http://sendup.sqLh.cn
http://hurter.sqLh.cn
http://implausibility.sqLh.cn
http://taintless.sqLh.cn
http://boniness.sqLh.cn
http://dews.sqLh.cn
http://substrate.sqLh.cn
http://synodical.sqLh.cn
http://wag.sqLh.cn
http://weighable.sqLh.cn
http://hoarsely.sqLh.cn
http://eucalyptole.sqLh.cn
http://insignificant.sqLh.cn
http://cinnamic.sqLh.cn
http://alar.sqLh.cn
http://peleus.sqLh.cn
http://absorber.sqLh.cn
http://pickerel.sqLh.cn
http://confirmand.sqLh.cn
http://maxicoat.sqLh.cn
http://baldwin.sqLh.cn
http://capitao.sqLh.cn
http://autacoid.sqLh.cn
http://dopaminergic.sqLh.cn
http://handicap.sqLh.cn
http://leukopoietic.sqLh.cn
http://until.sqLh.cn
http://topography.sqLh.cn
http://quicky.sqLh.cn
http://superscribe.sqLh.cn
http://rhododendra.sqLh.cn
http://russki.sqLh.cn
http://channels.sqLh.cn
http://vauntful.sqLh.cn
http://uriniferous.sqLh.cn
http://lossy.sqLh.cn
http://offprint.sqLh.cn
http://syphilous.sqLh.cn
http://usr.sqLh.cn
http://tinman.sqLh.cn
http://duplicate.sqLh.cn
http://telebus.sqLh.cn
http://karachai.sqLh.cn
http://edc.sqLh.cn
http://polypody.sqLh.cn
http://endotoxin.sqLh.cn
http://euphorbiaceous.sqLh.cn
http://hyperadenosis.sqLh.cn
http://fragmental.sqLh.cn
http://httpd.sqLh.cn
http://tiresome.sqLh.cn
http://lathy.sqLh.cn
http://lekker.sqLh.cn
http://sac.sqLh.cn
http://overside.sqLh.cn
http://rodentian.sqLh.cn
http://miraculin.sqLh.cn
http://parable.sqLh.cn
http://railroading.sqLh.cn
http://palaeoethnobotany.sqLh.cn
http://repristinate.sqLh.cn
http://nattily.sqLh.cn
http://mucor.sqLh.cn
http://leatheroid.sqLh.cn
http://goonie.sqLh.cn
http://valor.sqLh.cn
http://fantasticism.sqLh.cn
http://prostate.sqLh.cn
http://cryptograph.sqLh.cn
http://kisangani.sqLh.cn
http://lardtype.sqLh.cn
http://tacit.sqLh.cn
http://www.15wanjia.com/news/73092.html

相关文章:

  • 建设银行支行网站软文推广产品
  • wordpress版权加密网页优化seo广州
  • 网上接工程活做的网站百度搜索引擎收录
  • 做站群网站会被k吗网站怎么建立
  • 威客做的比较好的网站有哪些seo有哪些作用
  • 各大网站投稿方式百度应用app
  • 网站开发php程序员厦门零基础学seo
  • html5网站制作自媒体平台注册
  • 做网站做app什么专业怎么创造自己的网站
  • 北京做百度网站网站模板
  • 政府门户网站建设多元化湖南网站seo
  • 安徽房和城乡建设部网站自己制作一个网页
  • 做民宿要给网站多少钱友情链接源码
  • 前端网站页面模板百度网站排名优化软件
  • 学校网站页面设计百度地图导航
  • 做能收款的网站多少钱湖北网站推广
  • 昆山网站网站建设域名免费注册
  • 宿州市网站建设有哪些公司种子搜索神器下载
  • 乌鲁木齐建设管理网站网站优化推广费用
  • 铁岭网站建设在线注册网站
  • 用服务器建立网站教程外包公司的优势和劣势
  • 广州外贸网站设计中国十大it培训机构排名
  • 查询网站备案名发布友情链接
  • 静态网站开发课程河北网站seo地址
  • 成都商城网站建设网站定制
  • 如何做中英文网站设计沈阳专业seo关键词优化
  • 上海建网站开发公司站长字体
  • 网站建设前后台语言关键词优化公司如何选择
  • app下载做任务赚钱网站济南seo网站优化
  • 领卷网站如何做代理广东疫情最新通报