Fix SurfaceControl demo app layout

The fixes sizes could end up being wider than the screen (e.g on Pixel 3a)

PiperOrigin-RevId: 278642828
This commit is contained in:
olly 2019-11-05 17:28:21 +00:00 committed by Oliver Woodman
parent efc7f55616
commit f51f7bd405
2 changed files with 24 additions and 16 deletions

View File

@ -124,10 +124,10 @@ public final class MainActivity extends Activity {
}
gridLayout.addView(view);
GridLayout.LayoutParams layoutParams = new GridLayout.LayoutParams();
layoutParams.width = 400;
layoutParams.height = 400;
layoutParams.columnSpec = GridLayout.spec(i % 3);
layoutParams.rowSpec = GridLayout.spec(i / 3);
layoutParams.width = 0;
layoutParams.height = 0;
layoutParams.columnSpec = GridLayout.spec(i % 3, 1f);
layoutParams.rowSpec = GridLayout.spec(i / 3, 1f);
layoutParams.bottomMargin = 10;
layoutParams.leftMargin = 10;
layoutParams.topMargin = 10;

View File

@ -20,17 +20,17 @@
android:layout_height="match_parent"
android:keepScreenOn="true">
<GridLayout
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/grid_layout"
android:columnCount="3" />
android:orientation="vertical">
<SurfaceView
<GridLayout
android:id="@+id/grid_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/full_screen_view"
android:visibility="gone" />
android:layout_height="0dp"
android:layout_weight="1"
android:columnCount="3"/>
<com.google.android.exoplayer2.ui.PlayerControlView
android:id="@+id/player_control_view"
@ -39,5 +39,13 @@
android:layout_gravity="bottom"
app:show_timeout="0"/>
</LinearLayout>
<SurfaceView
android:id="@+id/full_screen_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"/>
</FrameLayout>