Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/208.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何确保回收器视图适配器项占据屏幕的全部高度_Android_Android Layout_Android Recyclerview_Android Constraintlayout - Fatal编程技术网

Android 如何确保回收器视图适配器项占据屏幕的全部高度

Android 如何确保回收器视图适配器项占据屏幕的全部高度,android,android-layout,android-recyclerview,android-constraintlayout,Android,Android Layout,Android Recyclerview,Android Constraintlayout,我有一个包含许多项目的recyclerview 但第一项类似于介绍屏幕,它有一个按钮,用户可以点击按钮查看更多信息,或者用户可以滚动查看更多数据 有点像跟踪 我希望这个按钮位于屏幕底部,在小型设备中,除非用户滚动视图,否则它不可见。所以,基本上布局是采取更多的高度,所以用户必须滚动查看完整的布局 我正在使用约束布局,并将其连接到视图的底部 视图中只有两个项目,一个是imageView,它没有任何图像,我只添加了背景色,另一个是TextView <androidx.constraintla

我有一个包含许多项目的recyclerview

但第一项类似于介绍屏幕,它有一个按钮,用户可以点击按钮查看更多信息,或者用户可以滚动查看更多数据

有点像跟踪

我希望这个按钮位于屏幕底部,在小型设备中,除非用户滚动视图,否则它不可见。所以,基本上布局是采取更多的高度,所以用户必须滚动查看完整的布局

我正在使用约束布局,并将其连接到视图的底部

视图中只有两个项目,一个是imageView,它没有任何图像,我只添加了背景色,另一个是TextView

<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto">
 
 
 <ImageView
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:background="@color/Black_Color"
        android:scaleType="centerCrop"

        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />
        
        
 <TextView
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginLeft="16dp"
        android:layout_marginRight="16dp"
        android:gravity="center"
        android:layout_marginBottom="50dp"
        android:textSize="17dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent" />

</      

在小型设备中,除非用户滚动视图,否则它是不可见的-听起来您的图像在小型设备中占据了很大的屏幕高度,因此用户必须滚动屏幕

如果您想“禁用”项目的滚动行为,并将所有内容都放在屏幕内(不将视图移出屏幕,从而使用户滚动),您可以更改布局,使项目只占据给定的屏幕高度,而不超过该高度,这样在小型设备上就不会出现此问题

大概是这样的:


诀窍是简单地以这样的百分比给出图像高度

  android:layout_height="0dp"
  app:layout_constraintHeight_percent="0.9"

现在,您的图像在每个屏幕大小上都将占据90%的高度。

需要更多详细信息。