如何最好地将模糊的ProgressBar放在屏幕上的ConstraintLayout上? [英] How to best place my obscured ProgressBar on a ConstraintLayout on the screen?
本文介绍了如何最好地将模糊的ProgressBar放在屏幕上的ConstraintLayout上?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我单击登录"按钮时,会显示一个进度条.我通过在顶部添加工具栏对布局进行了修改,看来此工具栏现在使进度栏变得晦涩.
I have a progress bar that shows up when I click on the Login button. I made modifications to the layout by adding a Toolbar at the top and it seems this toolbar is now obscuring the progressbar.
如何使进度条显示在屏幕中央某处?
How can I make this progress bar visible somewhere in the center of the screen?
非常感谢您的帮助.
布局xml代码如下所示:
The layout xml code is as shown below:
activity_login.xml
activity_login.xml
<android.support.constraint.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="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="16dp"
android:gravity="center"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
android:id="@+id/my_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:layout_marginBottom="64dp"
android:background="@android:color/white"
android:elevation="4dp"
android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
app:layout_constraintBottom_toTopOf="@+id/edittext_username"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
<EditText
android:id="@+id/edittext_username"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="24dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:drawablePadding="8dp"
android:gravity="center_vertical"
android:hint="@string/edittext_username"
app:layout_constraintBottom_toTopOf="@+id/edittext_password"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="@+id/button_login" />
<EditText
android:id="@+id/edittext_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="24dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:drawablePadding="8dp"
android:gravity="center_vertical"
android:hint="@string/edittext_password"
android:inputType="textPassword"
app:layout_constraintBottom_toTopOf="@+id/button_login"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent" />
<Button
android:id="@+id/button_login"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:text="@string/button_login"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent" />
<ProgressBar
android:id="@+id/progressbar_login_progress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:visibility="gone" />
</android.support.constraint.ConstraintLayout>
推荐答案
使用下一个代码将您的ProgressBar居中
Use next code to center your ProgressBar
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<ProgressBar
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/progressBar"
android:gravity="center"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>
这篇关于如何最好地将模糊的ProgressBar放在屏幕上的ConstraintLayout上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文