首页 > 解决方案 > 当进度条显示它改变了我的界面设计

问题描述

我期待我的进度条是这样的:

在此处输入图像描述

在不改变界面设计的情况下。

我的布局是这样的:

在此处输入图像描述

显示进度条后变为:

在此处输入图像描述

如您所见,它已将edittext 和其他一些设计推到了下面。

<RelativeLayout 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"
    tools:context=".Login">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:paddingLeft="24dp"
        android:paddingTop="56dp"
        android:paddingRight="24dp">

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="72dp"
            android:layout_gravity="center_horizontal"
            android:layout_marginBottom="24dp"
            android:src="@drawable/cenviro" />

        <com.rengwuxian.materialedittext.MaterialEditText
            android:id="@+id/input_email"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="8dp"
            android:layout_marginBottom="8dp"
            android:hint="Email"
            android:inputType="textEmailAddress"
            app:met_floatingLabel="highlight" />

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:layout_margin="16dp"
            android:visibility="gone"
            android:id="@+id/relativeLayout">

            <ProgressBar
                android:id="@+id/progressBar"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginBottom="20dp"
                android:indeterminate="true"
                android:indeterminateDrawable="@drawable/progress"
                android:max="100"/>

            <TextView
                android:id="@+id/title"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="Logging in..."
                android:textSize="20sp"
                android:layout_marginLeft="10dp"
                android:layout_marginStart="10dp"
                android:layout_marginTop="10dp"
                android:layout_toRightOf="@+id/progressBar"/>

        </RelativeLayout>

        <com.rengwuxian.materialedittext.MaterialEditText
            android:id="@+id/input_password"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="8dp"
            android:layout_marginBottom="8dp"
            android:hint="Password"
            android:inputType="textPassword"
            app:met_floatingLabel="highlight" />

如何在不改变我展示的第一张图片的界面的情况下显示进度条?

标签: androidandroid-progressbar

解决方案


在登录按钮下方添加此布局并从那里删除您的进度条布局。

<RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_margin="16dp"
            android:visibility="gone"
            android:id="@+id/relativeLayout">

            <ProgressBar
                android:id="@+id/progressBar"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginBottom="20dp"
                android:layout_centerInParent="true"
                android:indeterminate="true"
                android:indeterminateDrawable="@drawable/progress"
                android:max="100"/>

            <TextView
                android:id="@+id/title"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="Logging in..."
                android:textSize="20sp"
                android:layout_centerInParent="true"
                android:layout_marginLeft="10dp"
                android:layout_marginStart="10dp"
                android:layout_marginTop="10dp"
                android:layout_toRightOf="@+id/progressBar"/>

        </RelativeLayout>

推荐阅读