我将progressBar放在顶部的cardView中,代码如下:
<com.google.android.material.card.MaterialCardView
style="@style/Widget.MaterialComponents.CardView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/keyline_4"
android:layout_marginTop="@dimen/keyline_2"
android:layout_marginEnd="@dimen/keyline_4"
android:minHeight="200dp"
android:translationZ="8dp"
app:cardCornerRadius="@dimen/keyline_2"
app:cardElevation="@dimen/cardview_default_elevation"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="PrivateResource">
<ProgressBar
style="@style/Widget.AppCompat.ProgressBar.Horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:indeterminate="true" />
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.material.button.MaterialButton
android:id="@+id/forgotPassword"
style="@style/Widget.MaterialComponents.Button.OutlinedButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/keyline_4"
android:layout_marginTop="@dimen/keyline_1"
android:layout_marginEnd="@dimen/keyline_4"
android:layout_marginBottom="@dimen/keyline_4"
android:text="Forgot Password ?"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/signIn" />
<com.google.android.material.button.MaterialButton
android:id="@+id/signIn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/keyline_4"
android:backgroundTint="@color/color_secondary"
android:text="Sign In"
android:textColor="?colorOnSecondary"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/textInputPassword" />
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/textInputPassword"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/keyline_2"
android:paddingStart="@dimen/keyline_4"
android:paddingEnd="@dimen/keyline_4"
app:layout_constraintTop_toBottomOf="@id/textInputEmail"
app:passwordToggleEnabled="true">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/editTextPassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Password"
android:inputType="textPassword" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/textInputEmail"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/keyline_2"
android:paddingStart="@dimen/keyline_4"
android:paddingEnd="@dimen/keyline_4"
app:layout_constraintTop_toBottomOf="@id/rel">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/editTextMail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Email"
android:inputType="textEmailAddress" />
</com.google.android.material.textfield.TextInputLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.card.MaterialCardView>
我想像这样把它放在卡片视图的最顶端。它属于谷歌应用程序。 任何人都可以帮助我解决这个问题。我尝试过协调器布局、约束布局、相对布局等。我也尝试过改变progressBar的重力。它没有用。请帮忙。