I found a work around to this problem but it's not a real solution, Best answer will be marked as correct answer.
Work Around:
Add Views around your layout that needs the focus to stay with in itself. For Example:
<LinearLayout 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:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:orientation="horizontal"/>
<View
android:layout_width="0dp"
android:layout_height="match_parent"
android:focusable="true"
android:id="@+id/left_view"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<TextView
android:id="@+id/buyOrWatch"
android:layout_width="90dp"
android:layout_height="30dp"
android:layout_margin="5dp"
android:background="@drawable/movie_buy_selector"
android:focusable="true"
android:gravity="center"
android:text="@string/buy"
android:textColor="@color/color_white" />
<TextView
android:id="@+id/preview"
android:layout_width="90dp"
android:layout_height="30dp"
android:layout_margin="5dp"
android:layout_marginTop="15dp"
android:background="@drawable/movie_buy_selector"
android:focusable="true"
android:gravity="center"
android:text="@string/preview"
android:textColor="@color/color_white" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="0dp"
android:focusable="true"
android:id="@+id/right_view"/>
I placed the layout with the textviews in between the two focusable views with 0dp width.
Now, in your fragment class, bind those Views ,then define a focusChangeListener() for those views. for example if leftView binds view with id android:id="@+id/left_view" and buyOrWatch with TextView having android:id="@+id/buyOrWatch",then,
leftView.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View view, boolean hasFocus) {
if(hasFocus){
buyOrWatch.requestFocus();
}
}
});
You can define similar focus change listeners for each views like above, then as long as the fragment is visible, focus stays with in the fragment. Hope this helps someone.