Reputation: 51
I want to inflate new customized layout for my BrowseSupportFragment on my Android Tv app . I tried many ways but all of them was unsuccessful . The root layout for BrowseSupportFragment is lb_browse_fragment I tried to make new file with the same Id's it has and inflated it as follow but I got error . Can anybody help me on this case ?
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/browse_dummy"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<!-- BrowseFrameLayout serves as root of transition and manages switch between
left and right-->
<androidx.leanback.widget.BrowseFrameLayout
android:focusable="true"
android:focusableInTouchMode="true"
android:descendantFocusability="afterDescendants"
android:id="@+id/browse_frame"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.leanback.widget.BrowseRowsFrameLayout
android:id="@+id/browse_container_dock"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.leanback.widget.ScaleFrameLayout
android:id="@+id/scale_frame"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</androidx.leanback.widget.BrowseRowsFrameLayout>
<!-- Padding needed for shadow -->
<FrameLayout
android:id="@+id/browse_headers_dock"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:clipToPadding="false"
android:paddingEnd="50dp" />
</androidx.leanback.widget.BrowseFrameLayout>
my MainFragment extends BrowseSupportFragment :
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle
savedInstanceState) {
View view = inflater.inflate(R.layout.browse_fragment_costumized, container, false);
return view;
}
Upvotes: 0
Views: 946
Reputation: 9439
BrowseSupportFragment does a lot of setup in onCreateView, including ensuring overscan is handled and a lot of references are set. You can't use this Fragment in a meaningful way without calling through to onCreateView or you'll break all the assumptions it makes internally.
If you're substantially changing the layout, you shouldn't be using BrowseSupportFragment. If you just need to change some minor things, you can call through to the super onCreateView method and then modify the returned View.
Upvotes: 1