How can I remove blank space, as shown in dotted box in below image from BrowseFragment. I managed to remove search button and title. Although, I also want to remove blank space and move video row at top of screen.
Is there any way to do this?
I tried setting following in my AppTheme, but I doubt it helps:
<item name="browseRowsMarginTop">0dp</item>
<item name="browsePaddingTop">0dp</item>

You can do this using it's dimens.xml which is provided in v17 Lean Back library.
Follow the steps below first.
Go to your sdk -> extras -> android -> support -> v17 -> leanback -> res -> values.
From their copy dimens.xml file into your current leanback project values folder.
Now you have the dimens.xml file inside your project values folder.
Open that file and find below dimen.
Default value may be
167dpgiven.
<dimen name="lb_browse_rows_margin_top">167dp</dimen>
So change it to around
30dpor as per your need.
<dimen name="lb_browse_rows_margin_top">30dp</dimen>
You will get the rows up in Browse Fragment.
If you need to remove the header margin in only the fragment instead of globally overwrite the BrowseFragment:
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = super.onCreateView(inflater, container, savedInstanceState);
FrameLayout containerDock = (FrameLayout) view.findViewById(R.id.browse_container_dock);
FrameLayout.MarginLayoutParams params = (FrameLayout.MarginLayoutParams) containerDock.getLayoutParams();
Resources resources = inflater.getContext().getResources();
int newHeaderMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 30, resources.getDisplayMetrics());
int offsetToZero = -resources.getDimensionPixelSize(R.dimen.lb_browse_rows_margin_top);
params.topMargin = offsetToZero+newHeaderMargin;
containerDock.setLayoutParams(params);
return view;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With