How to move focus from RowsSupportFragment's row to next layout component?

Viewed 1411

I am using Android Leanback library for creating TV application. I have a layout which inflates Fragment (which is RowsSupportFragment) and below that there is button. So, when I scroll down to list of items in RowsSupportFragment after reaching to last item focus doesn't goes to button. I already have tried setting focusable(true), nextFocusDown(buttonId) etc.

I can see that RowsSupportFragment uses VerticalGridView internally to inflate list of items.

Do anybody has any idea about it?

here is my layout:

<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">

<FrameLayout
android:id="@+id/listviewFragmentId"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:duplicateParentState="true"
android:nextFocusDown="@id/nextButtonId"
android:nextFocusForward="@id/nextButtonId" 
layout_constraintBottom_toTopOf="@id/nextButtonId"/>

<Button
android:id="@+id/nextButtonId"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:duplicateParentState="true"
android:focusable="true"
android:text="Hello Next"/>

<// other items>
</android.support.constraint.ConstraintLayout>

Note: Focus works correctly if I left/right align button.

2 Answers

In My case this was work when i need focus on the any views

view.requestFocus();

In My case,i need focus on the any views on right outside of RowSupportFragment item so Working around with focusOutEnd,focusOutFront and other focus features in the Leanback Style solved my solution. like for requesting the focus to outside Button widget from RowSupportFragment, setting <item name="focusOutEnd">true</item> in style worked for me.

Related