说明
我正在使用一个回收站视图,其中包含的项目多于屏幕的高度,因此要查看它们,我们应该向下滚动。问题是我只能向下滚动某些[[dps(例如10或20 dps)。
我需要什么?
我需要滚动到它的底部才能看到all
回收商的视图。我的设计是私人的,所以我将向您展示图形:
蓝框是我的回收站视图。它已加载了十个视图,但我们只能看到两个半。我可以滑动,以便看到“爸爸洋基”的全名,但不能超过此。
我的片段XML代码(在有回收站的情况下)
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:contentDescription="@string/ayuda">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/constraint_bar"
android:layout_width="match_parent"
android:layout_height="50dp"
android:elevation="2dp"
android:contentDescription="@string/ayuda"
android:paddingTop="5dp"
android:paddingBottom="5dp"
android:background="#8d6e63"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ImageButton
android:id="@+id/imgbt_back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:contentDescription="@string/ayuda"
android:background="?selectableItemBackgroundBorderless"
android:src="@drawable/icon_back_negro"
android:tint="#ffffff"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/txt_lobby"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="15dp"
android:contentDescription="@string/ayuda"
android:text="Lobby"
android:textColor="#ffffff"
android:textSize="15.5sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@+id/imgbt_back"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<TextView
android:id="@+id/txt_names"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="20dp"
android:text="(10) names"
android:fontFamily="@font/arimo"
android:textColor="#000000"
android:textSize="16sp"
app:layout_constraintTop_toBottomOf="@id/constraint_bar"
app:layout_constraintLeft_toLeftOf="parent"
android:contentDescription="@string/ayuda"/>
<View
android:id="@+id/view_barra0"
android:layout_width="match_parent"
android:layout_height="1.5dp"
android:layout_marginTop="5dp"
android:background="#eeeeee"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@id/txt_names"
android:contentDescription="@string/ayuda"/>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_names"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="@id/view_barra0"
app:layout_constraintLeft_toLeftOf="parent"
android:contentDescription="@string/ayuda"/>
</androidx.constraintlayout.widget.ConstraintLayout>
我该怎么做才能将回收站滑到底部,以便能够看到所有其他视图?
id/recycler_names
上添加此约束:app:layout_constraintBottom_toBottomOf="parent"
然后将layout_height
设置为0dp
(匹配约束)。