答案 0 :(得分:0)
您可以使用ConstraintLayout
来解决此问题,例如:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/imageViewCenter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toTopOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="parent"
app:srcCompat="@drawable/drawable1" />
<ImageView
android:id="@+id/imageViewToPosition"
android:layout_width="50dp"
android:layout_height="50dp"
app:layout_constraintBottom_toTopOf="@id/imageViewCenter"
app:layout_constraintStart_toEndOf="@id/imageViewCenter"
app:layout_constraintEnd_toEndOf="@id/imageViewCenter"
app:layout_constraintTop_toTopOf="@id/imageViewCenter"
app:srcCompat="@drawable/drawable2" />
</android.support.constraint.ConstraintLayout>
如果您遇到约束布局问题,请考虑尝试codelab