Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Accessibility - Unable to focus on any element in the Appbar

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 -> 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) 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?

Here is the layout of Activity 2

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
    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: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>

I am unable to reach the toolbar_fav_icon ImageView

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!

Thanks!

Apoorva

like image 304
Apoorva Avatar asked Mar 09 '18 19:03

Apoorva


1 Answers

While i was working on accessibility in our app, i found out that i can't move focus to actionBar/toolbar views via bluetooth keyboard.

My test device is Samsung, so i thought that this is somth with navigation cluster, as described in some answers here...

but

In my case solution is - simply add this line to your appBar and/or toolbar

android:touchscreenBlocksFocus="false"
like image 78
whereismaxmax Avatar answered Sep 19 '22 19:09

whereismaxmax