android - 如何向 FragmentContainerView 添加可访问性委托?
问题描述
我需要添加与我的应用程序集成的 Google 地图的可访问性。我正在使用FragmentContainerView
集成SupportMapFragment
. 我的 XML 看起来像:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.fragment.app.FragmentContainerView
android:id="@+id/google_map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="270dp"
android:layout_marginTop="32dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:context=".MapsActivity" />
</androidx.constraintlayout.widget.ConstraintLayout>
在我的 MainFragment 中,我试图将可访问性委托设置为 google_map
google_map.accessibilityDelegate = object : View.AccessibilityDelegate() {
override fun onInitializeAccessibilityNodeInfo(host: View?, info: AccessibilityNodeInfo?) {
super.onInitializeAccessibilityNodeInfo(host, info)
Log.d("***", "Inside onInitializeAccessibilityNodeInfo")
}
}
但是在这种情况下accessibilityDelegate 不起作用。实际上onInitializeAccessibilityNodeInfo
方法没有被调用。你能帮我解决这个问题吗?
解决方案
推荐阅读
- php - Laravel:如何在 where 子句中混合 'and' 和 'or' 条件?
- url - 无法在 Slack API 中启用事件 URL
- image-processing - 计算表面法线贴图时发生了一些奇怪的事情
- git - 如何为 django 项目正确设置两个 .git 存储库
- javascript - 光滑的轮播忽略响应断点
- javascript - 找出 2 个多维数组之间的差异
- flutter - Flutter:如何使用 Firestore 检查连接性
- node.js - 单独文件中的NodeJS mysql2连接很快停止
- julia - Julia:子集数据框
- java - 如何为相同的功能处理两个不同的对象