我想使用 ImageView
和 ProgressBar
(在 ImageView 下方)创建 ConstraintLayout
:
<android.support.constraint.ConstraintLayout
android:id="@+id/loading_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000B4A">
<ImageView
android:id="@+id/imageView"
android:layout_width="200dp"
android:layout_height="200dp"
android:src="@mipmap/ic_launcher"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:contentDescription="" />
<ProgressBar
android:id="@+id/progressBar"
style="?android:attr/progressBarStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="@+id/imageView"
app:layout_constraintLeft_toLeftOf="@+id/imageView"
app:layout_constraintRight_toRightOf="@+id/imageView"
android:layout_marginTop="1250dp"/>
</android.support.constraint.ConstraintLayout>
当我实现它时,ProgressBar
不在 ImageView
下方,并且它们之间没有空间。
知道问题出在哪里吗?
附照片:
最佳答案
如果您希望进度条位于 ImageView 下方,则应使用 app:layout_constraintTop_toBottomOf="@+id/imageView"
将进度条的顶部与 ImageView 的底部对齐
<android.support.constraint.ConstraintLayout
android:id="@+id/loading_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000B4A">
<ImageView
android:id="@+id/imageView"
android:layout_width="200dp"
android:layout_height="200dp"
android:src="@mipmap/ic_launcher"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:contentDescription="" />
<ProgressBar
android:id="@+id/progressBar"
style="?android:attr/progressBarStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="72dp"
app:layout_constraintEnd_toEndOf="@+id/imageView"
app:layout_constraintStart_toStartOf="@+id/imageView"
app:layout_constraintTop_toBottomOf="@+id/imageView" />
</android.support.constraint.ConstraintLayout>
关于java - ImageView 到 ProgressBar 之间的 ConstraintLayout 空间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57448708/