2

I need to add extra button in title view on android tv app. How to allow to user move focus to extra button? I tied to use nextFocusRight to point the button or mark the button as focusable but without success.

I base on project: https://github.com/googlesamples/leanback-showcase

I added to custom_titleview.xml file the button in that showcase project and the file look like this:

<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

    <android.support.v17.leanback.widget.SearchOrbView
        android:nextFocusRight="@id/loginButton"
        android:id="@+id/search_orb"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:transitionGroup="true"
        android:layout_gravity="center_vertical|start"
        android:layout_marginTop="8dp"
        android:paddingStart="48dp" />

    <Button
        android:focusable="true"
        android:focusableInTouchMode="true"
        android:id="@+id/loginButton"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:text="Extra Button"
        android:layout_centerVertical="true"
        android:textColor="@color/login"
        android:layout_toEndOf="@+id/search_orb"
        android:transitionGroup="true"
        android:layout_gravity="center_vertical|start"/>

    <AnalogClock
            android:id="@+id/clock"
            android:layout_width="80dp"
            android:layout_height="80dp"
            android:padding="6dp"
            android:layout_alignParentEnd="true"
            android:layout_gravity="center_vertical|end"
            android:layout_marginEnd="24dp" />



    <TextView
            android:id="@+id/title_tv"
            android:textAppearance="@android:style/TextAppearance.Large"
            android:visibility="gone"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginEnd="24dp"
            android:layout_centerVertical="true"
            android:layout_toStartOf="@id/clock" />

</merge>

which give bellow screen: enter image description here but an user cannot move to "EXTRA BUTTON" using D-pad. Right arrow move the focus to main part of screen.

How to popper handle focus?

LunaVulpo
  • 3,043
  • 5
  • 30
  • 58

0 Answers0