Reputation: 345
I have problem with Android TV and I need your help.
Below is layout code:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<VideoView
android:id="@+id/videoView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
/>
<fragment
android:id="@+id/playback_controls_fragment"
android:name="com.sharewis.leonettv.PlaybackOverlayFragment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
And layout rendered:
How can I set position for Playback control of Android TV (etc: bottom, top...)?
Upvotes: 2
Views: 1233
Reputation: 5905
After updating to API v28 / leanback support v28.x.x I found the answer provided by Louis Nguyen to no longer be working.
Looking at the PlaybackSupportFragment.setVerticalGridViewLayout() source code for API 28 / Leanback support 28.x.x, one can see Google changed how this alignment is being set.
TLDR
If you're using API v28 / Leanback support v28.x.x :
"lb_playback_other_rows_center_to_bottom"
If you're using API v26 / Leanback support v26.x.x
"lb_playback_controls_padding_top"
Upvotes: 1
Reputation: 3
change the ViewGroup from to
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<VideoView
android:id="@+id/videoView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
/>
<fragment
android:id="@+id/playback_controls_fragment"
android:name="com.sharewis.leonettv.PlaybackOverlayFragment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
/>
</RelativeLayout>
and add two xml attributes layout_alignParentBottom and layout_centerHorizontal to fragment as shown above.
It aligns playback_control_fragment bottom edge of this view match the bottom edge of the parent and centers this child horizontally within its parent.
https://developer.android.com/reference/android/widget/RelativeLayout.LayoutParams.html
Upvotes: 0
Reputation: 345
I manual override padding dimen of Playback control (include top and bottom) with lb_playback_controls_padding_top and lb_playback_controls_padding_bottom
Upvotes: 0