相关疑难解决方法(0)

是否有与RecyclerView相同的addHeaderView?

我正在为回收者视图寻找相当于addHeaderView的东西.基本上我想要一个带有2个按钮的图像作为标题添加到列表视图中.是否有不同的方法将标题视图添加到回收站视图?指导的一个例子会很有帮助

编辑2(添加片段布局):

添加日志语句后,似乎getViewType只接收到0的位置.这导致onCreateView只加载一个布局:

10-26 16:32:53.766    5449-5449/co.testapp I/logger info? Adapter-> getItemCount: 5
10-26 16:32:53.766    5449-5449/co.testapp I/logger info? Adapter-> getItemCount: 5
10-26 16:32:53.766    5449-5449/co.testapp I/logger info? Adapter-> getItemCount: 5
10-26 16:32:53.766    5449-5449/co.testapp I/logger info? Adapter-> getItemCount: 5
10-26 16:32:53.766    5449-5449/co.testapp I/logger info? Adapter-> getItemCount: 5
10-26 16:32:53.766    5449-5449/co.testapp I/logger info? Adapter-> getItemCount: 5
10-26 16:32:53.766    5449-5449/co.testapp I/logger info? Adapter-> getItemCount: 5
10-26 16:32:53.766    5449-5449/co.testapp I/logger info? Adapter-> getItemCount: 5
10-26 16:32:53.766    5449-5449/co.testapp I/logger info? Adapter-> getItemCount: 5
10-26 16:32:53.766    5449-5449/co.testapp I/logger info? …
Run Code Online (Sandbox Code Playgroud)

android android-view android-recyclerview

279
推荐指数
10
解决办法
19万
查看次数

RecyclerView页眉和页脚

也许之前已经问过这个问题,但我似乎无法找到准确的答案或解决方案.我开始使用RecyclerView,并使用LinearLayoutManager实现它.现在我想添加自定义页眉和页脚项目,这些项目与我的RecyclerView中的其他项目不同.页眉和页脚不应该是粘性的,我希望它们与其余项目一起滚动.有人可以指出一些例子如何做到这一点或只是分享想法.我会非常感激.谢谢

android header footer android-5.0-lollipop android-recyclerview

52
推荐指数
5
解决办法
7万
查看次数

使用RecyclerView进行视差标题效果

我想更改我目前已经使用的ListView,RecyclerView所以我可以使用StaggeredGridLayoutManager但是RecyclerView没有能力添加像ListView这样的标题.

通常使用ListView我在标题中设置一个空视图,并将图像放在listview下面,并通过滚动列表来转换底部图像以创建Parallax效果.

因此,如果没有标题,我怎样才能创建相同的视差效果RecyclerView

android android-recyclerview

15
推荐指数
2
解决办法
2万
查看次数

在nestedscrollview中的recyclerview中将项目拖出可见空间时 - nestedscrollView不会滚动

我有一个建筑,其中有两个项目是静态和recyclerview与可拖动的项目.两种类型的视图都由LinearLayout包装.LinearLayout由NestedScrollView包装.

XML说明:

<NestScrollView>
  <LinearLayout>
    <View></View>
    <View></View>
    <RecyclerView></RecyclerView>
  </LinearLayout>
</NestScrollView>
Run Code Online (Sandbox Code Playgroud)

图解说明:

在此输入图像描述

我从本教程中拖拽项目的实现:https://medium.com/@ipaulpro/drag-and-swipe-with-recyclerview-6a6f0c422efd#.yc7me2ikf

问题是RecyclerView当我将他的孩子拖出屏幕时不会滚动.(但是,如果我没有NestedScrollView作为父母,RecyclerView按预期工作.)

我搜索了与此相关的每个问题,但我没有找到任何解决方案.

android drag-and-drop android-nestedscrollview

11
推荐指数
1
解决办法
1473
查看次数

如何在android中的相同recyclerview中填充具有相同字段或属性的不同对象

我将开发足球应用程序,并跟随json响应.(链接)

我有两个不同的类,具有不同的名称,但具有相同的属性或字段,并希望显示一个相同的单一RecyclerView.

在这里,我有worldmatch和世界具有类似于相同的字段matchTime,startTime以及endTime.我使用jsontopojo插件创建了pojo类.

这是主要的事情,我想显示worldmatch在0位置,并根据俱乐部的其他位置世界其他地区.您可以在图片中查看更多详细信息.

在此输入图像描述

在此输入图像描述

这必须是第一个标签(世界),类似于欧洲,亚洲等具有相似模式的其他标签.

TAB1(世界)

---------------position 0 (All match)------------------
|
| 930   1100   1130  and so on ( horizontal recyclerview)
|
-------------------------------------------
---------------position 1(Barcelona)------------------
|
| 1130   1230   1330   1430  and so on (  horizontal recyclerview)
|
-------------------------------------------
---------------position 2(Chelsea)------------------
|
| 1300   1400   1500  and so on (  horizontal recyclerview)
|
-------------------------------------------
                     .
                     .
                     .
                   so on
        (vertical …
Run Code Online (Sandbox Code Playgroud)

java android android-recyclerview nestedrecyclerview

10
推荐指数
1
解决办法
452
查看次数

androidx Recycler View 匹配约束 (0dp) 与换行内容行为

我这里有简单的回收器视图,我想要的是:

当列表很短时:将按钮粘贴在回收器视图下方

当列表很长时:将按钮粘在屏幕底部,但回收器视图正确换行并且能够滚动到底部

<?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"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/rv_user_address"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginStart="20dp"
        android:layout_marginTop="15dp"
        android:layout_marginEnd="20dp"
        app:layout_constraintBottom_toTopOf="@id/btn"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_chainStyle="packed"
        app:layout_constraintVertical_bias="0.0"
        tools:itemCount="50"/>

    <Button
        android:id="@+id/btn"
        android:layout_width="match_parent"
        android:layout_height="40dp"
        android:layout_marginStart="20dp"
        android:layout_marginTop="20dp"
        android:layout_marginEnd="20dp"
        android:layout_marginBottom="20dp"
        android:text="example"
        android:background="#00ffff"
        android:gravity="center"
        android:orientation="horizontal"
        app:layout_constraintTop_toBottomOf="@id/rv_user_address"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"/>

</androidx.constraintlayout.widget.ConstraintLayout>
Run Code Online (Sandbox Code Playgroud)

什么时候wrap_content

<androidx.recyclerview.widget.RecyclerView
android:layout_height="wrap_content"
...
Run Code Online (Sandbox Code Playgroud)

短列表可以正确地将按钮粘贴在下面,但当列表很长时按钮会离开屏幕

什么时候是约束:0dp:

<androidx.recyclerview.widget.RecyclerView
android:layout_height="0dp"
...
Run Code Online (Sandbox Code Playgroud)

长列表是正确的行为,但短列表不能将按钮粘贴在列表下方

我不知道了。谢谢你的帮助。

在此输入图像描述在此输入图像描述在此输入图像描述在此输入图像描述

android android-recyclerview android-constraintlayout

7
推荐指数
1
解决办法
1745
查看次数

滚动nestedscrollview到子recyclerview滚动之前结束

这是我的 layout

________________  ___   
|              |   ||
| Linear       |   ||
| Layout       |   ||
|              |   || nested scroll view
|______________|   ||
||            ||   ||
||            ||   ||
||   Child    ||  _||
||Recyclerview||
||____________||
|______________|      -end
Run Code Online (Sandbox Code Playgroud)

如何使父级LinearLayout先滚动,到达末尾时,子级recyclerview应该滚动。

默认情况下RecyclerView,在父级开始滚动之前,子级首先滚动到结尾。

android android-scrollview android-recyclerview nestedscrollview

5
推荐指数
1
解决办法
857
查看次数

ScrollView中的RecyclerView wrap_content高度未按预期工作

我有一个RecyclerView嵌入式ScrollView.这是完整的布局:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent">

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fillViewport="true"
        android:orientation="vertical">

        <LinearLayout
            android:layout_width="match_parent"
            android:orientation="vertical"
            android:layout_height="wrap_content">

            <fragment
                android:name="devarshi.sample.view.ProductPortfolioFragment"
                android:id="@+id/fragmentProductPortfolio"
                android:layout_width="match_parent"
                android:layout_margin="10dp"
                android:layout_height="230dp" />

            <LinearLayout
                android:orientation="vertical"
                android:layout_width="match_parent"
                android:layout_height="wrap_content">

                <TextView
                    android:text="TextView"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:id="@+id/textViewProductName" />

                <TextView
                    android:text="TextView"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:id="@+id/textViewProductDescription" />

                <LinearLayout
                    android:id="@+id/linearLayoutProductDetails"
                    android:orientation="vertical"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content">

                    <TextView
                        android:text="@string/product_detail_title"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:id="@+id/textViewProductDetails" />
                </LinearLayout>
            </LinearLayout>

            <LinearLayout
                android:orientation="horizontal"
                android:layout_width="match_parent"
                android:id="@+id/linearyLayoutOtherProductDetails"
                android:layout_height="100dp">

                <LinearLayout
                    android:orientation="vertical"
                    android:layout_width="0dp"
                    android:layout_weight="0.6"
                    android:layout_height="wrap_content">

                    <LinearLayout
                        android:layout_width="match_parent"
                        android:orientation="horizontal"
                        android:id="@+id/linearLayoutPrice"
                        android:layout_height="wrap_content">

                        <TextView
                            android:id="@+id/textViewProductPrice"
                            android:layout_width="wrap_content"
                            android:textSize="15sp"
                            android:textStyle="bold"
                            android:textColor="@color/colorDiscountedPrice" …
Run Code Online (Sandbox Code Playgroud)

java android android-scrollview android-recyclerview

3
推荐指数
2
解决办法
2320
查看次数