问题描述
限时送ChatGPT账号..我在 2 个活动中遇到了这个问题.当我使用键盘 Tab 键或箭头键导航时 - 我无法访问应用栏中的任何元素.
I have this issue in 2 of my activities. When I navigate using keyboard Tab keys or arrow keys - I am unable to reach any element in the App bar.
1) Activity 1 -> 我的 appbar 有一个汉堡菜单图标来访问 NavigationView.我无法单击此图标.如果我触摸菜单图标 - 我可以使用键盘在菜单项上下导航.但是我如何进入菜单?
1) Activity 1 -> My appbar has a hamburger menu icon to access the NavigationView. I am not able to click on this icon. If I touch the menu icon - I can navigate up and down the menu items with my keyboard. But how do I get into the menu?
2) 活动 2 - 我有一个 CoordinatorLayout,里面有一个 CollapsingToolbarLayout 和一个 NestedScrollView.我能够导航到 NestedScrollView 的所有元素.但是我无法到达 CollapsingToolbarLayout 内工具栏上的任何按钮.它有一个收藏夹按钮和一个选项菜单 - 溢出图标和我总是在应用栏上显示的 1.如何访问这些图标?
2) Activity 2 - I have a CoordinatorLayout with a CollapsingToolbarLayout inside it and a NestedScrollView. I am able to navigate to all elements of the NestedScrollView. But am not able to reach any buttons on the toolbar inside the CollapsingToolbarLayout. This has a button for favorites and an options menu - overflow icon and 1 that I always show on the appbar. How do I reach these icons?
这是Activity 2的布局
Here is the layout of Activity 2
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android/apk/res/android"
xmlns:app="http://schemas.android/apk/res-auto"
xmlns:tools="http://schemas.android/tools"
android:id="@+id/root_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:id="@+id/detail_app_bar_layout"
android:layout_width="match_parent"
android:layout_height="@dimen/place_detail_appbar_height"
android:elevation="@dimen/place_detail_appbarlayout_elevation">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/detail_collapsing_toolbar_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorPrimary"
android:transitionGroup="false"
app:collapsedTitleGravity="start"
app:collapsedTitleTextAppearance="@style/TextAppearance.AppCompat.Widget.ActionBar.Title.Inverse"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleMarginStart="72dp"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<ImageView
android:id="@+id/detail_app_bar_photo"
android:layout_height="match_parent"
android:layout_gravity="center"
android:scaleType="centerCrop"
app:layout_collapseMode="parallax"
android:background="@color/colorPrimary"
android:contentDescription="@string/place_image"
android:transitionName="@string/shared_photo"
style="@style/ToolbarImage"/>
<android.support.v7.widget.Toolbar
android:id="@+id/detail_toolbar"
android:layout_width="match_parent"
android:layout_height="@dimen/place_detail_toolbar_height"
android:background="@color/colorAccent"
app:layout_collapseMode="pin"
android:layout_gravity="bottom"
android:theme="@style/AppTheme.ToolbarColored">
<LinearLayout
android:id="@+id/meta_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="start"
android:background="@android:color/transparent"
android:orientation="horizontal">
<TextView
android:id="@+id/toolbar_place_name"
style="@style/ToolbarName"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="4"
android:layout_gravity="center_vertical|start"
tools:text="OFJCC Gym and Recreation Center" />
<ImageView
android:id="@+id/toolbar_fav_icon"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
app:srcCompat="@drawable/ic_favourite_border"
android:tag="favorite_border"
android:layout_gravity="center"
android:focusable="true"
android:contentDescription="@string/favorite_desc"/>
</LinearLayout>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:nextFocusUp="@+id/toolbar_fav_icon"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<include layout="@layout/place_details_content"/>
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>
</FrameLayout>
我无法访问 toolbar_fav_icon ImageView
I am unable to reach the toolbar_fav_icon ImageView
这两种情况之间唯一的共同点是在这两种情况下 - 我在访问 Appbar 上的元素时遇到问题.我是一个新手,我可能遗漏了一些非常明显的东西.请耐心等待并帮助我!
The only commonality between these 2 situations is that in both cases - I am having issues reaching elements on the Appbar. I am a newbie and there might be something super obvious I am missing. Please bear with me and help me out!
谢谢!
阿普尔瓦
推荐答案
您是否尝试按下组合键 Cmd+Tab(在 Mac 上)或 Ctrl+Tab(在 Windows 上)?
Did you try hitting the key combinations Cmd+Tab (on Mac) or Ctrl+Tab (on Windows)?
Android 引入了键盘导航集群的新概念,并将 Toolbar 标记为 API 26+ 的导航集群.因此,仅通过 Tab 键无法访问工具栏元素,您需要元选项卡"(Ctrl/Cmd + Tab)才能访问 API 26 及更高版本设备的工具栏.
Android introduced new concept of keyboard navigation clustering and marked Toolbar as a navigation cluster for API 26+. Due to this, Toolbar elements are inaccessible via just the tab key, and you need to 'meta-tab' (Ctrl/Cmd + Tab) to reach the toolbar for devices on API 26 and above.
这篇关于Android 辅助功能 - 无法专注于 Appbar 中的任何元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
更多推荐
[db:关键词]
发布评论