2

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.

Sumit T
  • 1,273
  • 2
  • 17
  • 32

2 Answers2

0

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

view.requestFocus();
Jignesh Mayani
  • 6,937
  • 1
  • 20
  • 36
  • 1
    issue is, as the focus is inside VerticalGridView items and so either I have check once the focus comes to last item than I have to request focus on button which is outside of RowsSupportFragment (means at activity level) – Sumit T Oct 11 '19 at 17:27
0

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.