java - ImageView 到 ProgressBar 之间的 ConstraintLayout 空间

标签 java android android-studio

我想使用 ImageViewProgressBar(在 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 下方,并且它们之间没有空间。

知道问题出在哪里吗?

附照片:

enter image description here

最佳答案

如果您希望进度条位于 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>

enter image description here

关于java - ImageView 到 ProgressBar 之间的 ConstraintLayout 空间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57448708/

相关文章:

android - notifydatasetchanged 内部 fragment 与 ListView

java - 如何始终检查Android中的状况?

java - android 屏幕作为内联网中的 pc 触摸板

java - 关于我的服务应该如何交互的建议

android - 无法使用 ViewModelFactory 实例化我的 ViewModel

android - 如何删除android中的NFC标签数据?

java - 运行应用程序时布局不显示

java - 谷歌地图 : Saving markers to text file/other?

java - AsynchronousByteChannel 的线程含义

java - 单词末尾加号的正则表达式