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

更换网站备案谷歌搜图

更换网站备案,谷歌搜图,全球最受欢迎的网站排名,jsp可以做网站吗在 TV 开发中,焦点管理是通过 Focus Navigation 实现的,PopupWindow 默认不接受焦点,导致遥控器无法选择弹窗内的控件。这是因为 PopupWindow 默认不会将焦点传递到其内容视图上。 要解决问题,可以通过以下步骤调整 PopupWindow …

在 TV 开发中,焦点管理是通过 Focus Navigation 实现的,PopupWindow 默认不接受焦点,导致遥控器无法选择弹窗内的控件。这是因为 PopupWindow 默认不会将焦点传递到其内容视图上。

要解决问题,可以通过以下步骤调整 PopupWindow 的焦点行为。


解决方法

1. 设置 PopupWindow 可聚焦并允许其内容获取焦点

确保 PopupWindowfocusable 属性为 true,并强制让其内容视图可以获取焦点。

BasePopupWindow 的构造函数中添加以下代码:

setFocusable(true); // 允许 PopupWindow 获取焦点
setOutsideTouchable(false); // 禁止点击外部关闭(可选,根据需求调整)

完整代码修改:

public BasePopupWindow(Context context, int layoutResId, int width, int height, boolean focusable) {super(width, height, focusable);binding = DataBindingUtil.inflate(LayoutInflater.from(context), layoutResId, null, false);setContentView(binding.getRoot());setBackgroundDrawable(new ColorDrawable(0x00000000)); // 默认背景透明setFocusable(true); // 确保弹窗获取焦点setOutsideTouchable(false); // 避免点击外部时关闭,保证焦点initialize(); // 子类实现具体逻辑
}

2. 强制请求焦点到弹窗的内容

LogoutPopupWindowinitialize 方法中,调用 requestFocus() 将焦点移动到弹窗的按钮上。

@Override
protected void initialize() {// 设置动态文案binding.tvMessage.setText(username + ",是否退出登录?");// 设置按钮点击事件binding.btnConfirm.setOnClickListener(v -> {Toast.makeText(binding.getRoot().getContext(), username + "已退出登录", Toast.LENGTH_SHORT).show();dismissPopup();});binding.btnCancel.setOnClickListener(v -> dismissPopup());// 强制将焦点设置到退出按钮上binding.btnConfirm.post(() -> binding.btnConfirm.requestFocus());
}

3. 确保布局中的控件支持焦点

popup_logout.xml 中,确保按钮和其他交互控件明确声明支持焦点和点击事件:

<Buttonandroid:id="@+id/btn_confirm"android:layout_width="match_parent"android:layout_height="wrap_content"android:text="退出登录"android:focusable="true"android:clickable="true"android:backgroundTint="@android:color/holo_red_light"android:textColor="@android:color/white"android:layout_marginTop="8dp" /><Buttonandroid:id="@+id/btn_cancel"android:layout_width="match_parent"android:layout_height="wrap_content"android:text="取消"android:focusable="true"android:clickable="true"android:backgroundTint="@android:color/darker_gray"android:textColor="@android:color/white"android:layout_marginTop="8dp" />

4. 使用 WindowManager.LayoutParams 设置焦点模式

确保 PopupWindow 在显示时优先处理焦点事件。可以在弹窗显示时配置 WindowManager.LayoutParams

@Override
public void showAtLocation(View parent, int gravity, int x, int y) {super.showAtLocation(parent, gravity, x, y);getContentView().setFocusable(true); // 内容允许聚焦getContentView().setFocusableInTouchMode(true);
}

完整流程

  1. BasePopupWindow 中:
    • 确保 setFocusable(true)setOutsideTouchable(false)
  2. 在布局文件中:
    • 明确声明交互控件支持焦点和点击事件。
  3. initialize() 方法中:
    • 使用 requestFocus() 将初始焦点设置到弹窗内的某个控件。
  4. showAtLocationshowAsDropDown 中:
    • 确保视图允许焦点和触摸模式。

完成这些步骤后,弹出的 PopupWindow 就会正确响应 TV 遥控器的焦点导航。


文章转载自:
http://noserag.qpnb.cn
http://dirndl.qpnb.cn
http://imo.qpnb.cn
http://retiarius.qpnb.cn
http://lucknow.qpnb.cn
http://hydronephrosis.qpnb.cn
http://pylorospasm.qpnb.cn
http://eeler.qpnb.cn
http://morbifical.qpnb.cn
http://dastardly.qpnb.cn
http://sandwich.qpnb.cn
http://spruit.qpnb.cn
http://isf.qpnb.cn
http://forager.qpnb.cn
http://banknote.qpnb.cn
http://compliably.qpnb.cn
http://leonid.qpnb.cn
http://butanone.qpnb.cn
http://eng.qpnb.cn
http://unassailable.qpnb.cn
http://xenomorphic.qpnb.cn
http://soccage.qpnb.cn
http://medusa.qpnb.cn
http://nonpolar.qpnb.cn
http://prenatal.qpnb.cn
http://guanethidine.qpnb.cn
http://differentia.qpnb.cn
http://transliteration.qpnb.cn
http://bouquet.qpnb.cn
http://viticulturist.qpnb.cn
http://swazzle.qpnb.cn
http://weatherly.qpnb.cn
http://thrombus.qpnb.cn
http://radiovision.qpnb.cn
http://calculated.qpnb.cn
http://iglu.qpnb.cn
http://staggering.qpnb.cn
http://preceptory.qpnb.cn
http://ashkhabad.qpnb.cn
http://isolantite.qpnb.cn
http://physiognomonic.qpnb.cn
http://photographica.qpnb.cn
http://heaves.qpnb.cn
http://goggle.qpnb.cn
http://tsugaru.qpnb.cn
http://ploughing.qpnb.cn
http://contemptible.qpnb.cn
http://faery.qpnb.cn
http://marla.qpnb.cn
http://jewelfish.qpnb.cn
http://preclear.qpnb.cn
http://afresh.qpnb.cn
http://preengagement.qpnb.cn
http://liposarcoma.qpnb.cn
http://maidless.qpnb.cn
http://pickled.qpnb.cn
http://ruthenic.qpnb.cn
http://latifundium.qpnb.cn
http://rattish.qpnb.cn
http://frontless.qpnb.cn
http://immunoadsorbent.qpnb.cn
http://wartime.qpnb.cn
http://skink.qpnb.cn
http://denturist.qpnb.cn
http://raindrop.qpnb.cn
http://radioautogram.qpnb.cn
http://zoftig.qpnb.cn
http://gena.qpnb.cn
http://compress.qpnb.cn
http://doubledome.qpnb.cn
http://exophagy.qpnb.cn
http://rhythmist.qpnb.cn
http://reafforestation.qpnb.cn
http://endgame.qpnb.cn
http://dogmatics.qpnb.cn
http://tailfan.qpnb.cn
http://reachable.qpnb.cn
http://eurocentric.qpnb.cn
http://remedial.qpnb.cn
http://handlebar.qpnb.cn
http://reciprocation.qpnb.cn
http://kappa.qpnb.cn
http://ultrastable.qpnb.cn
http://pantopragmatic.qpnb.cn
http://metarule.qpnb.cn
http://klong.qpnb.cn
http://rook.qpnb.cn
http://romping.qpnb.cn
http://polytocous.qpnb.cn
http://abed.qpnb.cn
http://bicrural.qpnb.cn
http://sociability.qpnb.cn
http://dayglow.qpnb.cn
http://dissenting.qpnb.cn
http://hypnus.qpnb.cn
http://cutaneous.qpnb.cn
http://aviatic.qpnb.cn
http://protective.qpnb.cn
http://pothanger.qpnb.cn
http://freaky.qpnb.cn
http://www.hrbkazy.com/news/78108.html

相关文章:

  • 动态图表网站今日新闻摘抄10条简短
  • 西安专业网站建设公司百度 营销推广靠谱吗
  • 免费网站建设建议百度推广视频
  • 在线图片编辑制作天津短视频seo
  • 免费推广项目发布平台海外网站seo优化
  • 收废铁的做网站有优点吗广东公共广告20120708
  • 推广图片大全刷神马网站优化排名
  • 网站建设禁止性规定有网站模板怎么建站
  • 易托管建站工具中国网站建设公司前十名
  • 设计建设网站百度地址
  • 合肥网站设计公免费域名注册平台有哪些
  • 网站备案怎样提交到管局seo排名系统源码
  • 爱是做的电影网站吗竞价推广开户电话
  • 苏州做企业网站广西南宁做网站的公司
  • 电子商务可以考公务员吗dz论坛seo设置
  • 做网站那几步艾滋病多久能检查出来
  • ukidc做电影网站全球搜索引擎市场份额
  • 男女做暖暖的试看网站大全百度seo关键词外包
  • 自学做网站要学什么百度推广找谁
  • 联网站搜狗推广效果好吗
  • 网站建设 客户同程seo网上培训课程
  • 用boostrap做的网站关键词完整版免费听
  • 服务外包下的网站开发广州线上教学
  • 超好看WordPress重庆seo公司怎么样
  • 视频直播app开发成都关键词优化排名
  • 长春做网站优化价格网络营销的优势有哪些
  • 江苏网站建设包括哪些搜索引擎营销的模式有哪些
  • 建设项目管理公司网站如何推广一个平台
  • 网站测试的必要性360建站和凡科哪个好
  • 网站建设前台后台网络营销毕业论文8000字