Android 辅助功能

编程入门 行业动态 更新时间:2024-10-24 14:16:12
本文介绍了Android 辅助功能 - 无法专注于 Appbar 中的任何元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送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:关键词]

本文发布于:2023-04-23 03:36:28,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1034452.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:辅助功能   Android

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!