用的ConstraintLayout,第一排3个button横向平均分布,离顶16dp。
第二行videoView,高度wrap_content,我想让videoView离button16dp,离底部16dp,不知道要怎么设置才正确了。
1,同时设置到button下面和父局底部的限位,videoView会遮挡button和底部超出父布局;
2,单独设置离button下面限位,videoView会超出底部父布局;
3,单独设置离父布局底部限位,videoView会遮挡button,
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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"
tools:context=".MainActivity">
<Button
android:id="@+id/btn1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/play"
android:layout_marginTop="16dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@id/btn2"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="@+id/btn2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/pause"
android:layout_marginTop="16dp"
app:layout_constraintLeft_toRightOf="@id/btn1"
app:layout_constraintRight_toLeftOf="@id/btn3"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="@+id/btn3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/replay"
android:layout_marginTop="16dp"
app:layout_constraintLeft_toRightOf="@id/btn2"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<VideoView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
app:layout_constraintTop_toBottomOf="@id/btn2"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginBottom="16dp"/>
</androidx.constraintlayout.widget.ConstraintLayout>