我的底部布局有问题,我的约束布局没有完全填满滚动视图(下面是空格)。这是问题的图像证据。 在这种情况下,我希望灰色背景填充下面的白色空间。我在所有方面都尝试过匹配父母,但它不起作用。
这是我的xml文件,属于我上传的布局
<?xml version="1.0" encoding="utf-8"?>
<layout 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:id="@+id/layout">
<data>
<variable
name="viewModel"
type="com.repsol.repsolmove.ui.login.LoginViewModel" />
</data>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.core.widget.NestedScrollView
android:id="@+id/scrolView"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/imageView"
android:layout_width="174dp"
android:layout_height="70dp"
android:layout_marginStart="8dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="3dp"
android:src="@drawable/ic_img_logo_repsolmove"
app:layout_constraintBottom_toTopOf="@+id/imageBottomMargin"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.repsol.repsolmove.ui.widgets.RepsolInputLayout
android:id="@+id/login"
android:layout_width="0dp"
android:layout_height="105dp"
android:layout_marginTop="30dp"
app:errorText="@string/invalid_card_number"
app:layout_constraintEnd_toStartOf="@+id/marginEnd"
app:layout_constraintStart_toStartOf="@+id/marginStart"
app:layout_constraintTop_toBottomOf="@+id/imageView"
app:titleText="@string/login_title" />
<com.repsol.repsolmove.ui.widgets.RepsolInputLayout
android:id="@+id/password"
android:layout_width="0dp"
android:layout_height="105dp"
app:errorText="@string/invalid_password"
app:isPassword="true"
app:layout_constraintEnd_toStartOf="@+id/marginEnd"
app:layout_constraintStart_toStartOf="@+id/marginStart"
app:layout_constraintTop_toBottomOf="@+id/login"
app:titleText="@string/password_title" />
<TextView
android:id="@+id/newPassword"
style="@style/RepsolText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:layout_marginEnd="8dp"
android:fontFamily="@font/repsol_regular"
android:text="@string/new_password"
android:textSize="16dp"
app:layout_constraintEnd_toStartOf="@+id/marginEnd"
app:layout_constraintTop_toBottomOf="@+id/password" />
<Button
android:id="@+id/btnLogin"
android:layout_width="228dp"
android:layout_height="50dp"
android:layout_marginStart="8dp"
android:layout_marginTop="32dp"
android:layout_marginEnd="8dp"
android:background="@drawable/shape_rounded_fill_rectangle"
android:fontFamily="@font/repsol_regular"
android:text="@string/login"
android:textAllCaps="false"
android:textColor="@android:color/white"
android:textSize="16sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/newPassword" />
<Button
android:id="@+id/btnJoin"
android:layout_width="0dp"
android:layout_height="51dp"
android:layout_marginStart="8dp"
android:layout_marginTop="32dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="32dp"
android:background="@drawable/shape_rounded_rectangle"
android:fontFamily="@font/repsol_regular"
android:text="@string/join"
android:textAllCaps="false"
android:textColor="@color/colorPrimaryDark"
android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/btnNologin"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintStart_toStartOf="@+id/marginStart"
app:layout_constraintTop_toBottomOf="@+id/btnLogin"
app:layout_constraintVertical_bias="0.75" />
<Button
android:id="@+id/btnNologin"
android:layout_width="0dp"
android:layout_height="51dp"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="32dp"
android:background="@drawable/shape_rounded_no_stroke_rectangle"
android:fontFamily="@font/repsol_regular"
android:text="@string/enter_without_login"
android:textAllCaps="false"
android:textColor="@color/colorPrimaryDark"
android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/marginEnd"
app:layout_constraintStart_toEndOf="@+id/btnJoin"
app:layout_constraintTop_toBottomOf="@+id/btnLogin"
app:layout_constraintVertical_bias="0.75" />
<androidx.constraintlayout.widget.Guideline
android:id="@+id/imageBottomMargin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.30" />
<androidx.constraintlayout.widget.Guideline
android:id="@+id/marginStart"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.10" />
<androidx.constraintlayout.widget.Guideline
android:id="@+id/marginEnd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.90" />
<com.repsol.repsolmove.ui.widgets.RepsolDialog
android:id="@+id/dialog"
android:layout_width="match_parent"
android:layout_height="0dp"
android:elevation="10dp"
android:visibility="visible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<include
android:id="@+id/loading"
layout="@layout/loading"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView>
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
答案 0 :(得分:2)
将此属性添加到xml文件中的NestScrollView元素
android:fillViewport="true"