Android 设置内部回收视图包裹内容的高度

Android 设置内部回收视图包裹内容的高度,android,android-recyclerview,Android,Android Recyclerview,我在另一个回收视图中有一个回收视图。我想让内部回收高度查看“扭曲内容” 我知道这是有可能的新版本的recyclerview,这是下面提到的 'com.android.support:recyclerview-v7:23.2.0' 但问题是,通过设置height=wrap\u content,我只能看到第一项 任何帮助都会很好。因为我使用的是RecyclerView这不起作用,请参见: 及 嵌套回收器视图高度不包装其内容 在这两个页面上,人们建议扩展LinearLayoutManager并覆盖

我在另一个回收视图中有一个回收视图。我想让内部回收高度查看“扭曲内容”

我知道这是有可能的新版本的recyclerview,这是下面提到的

'com.android.support:recyclerview-v7:23.2.0'
但问题是,通过设置height=wrap\u content,我只能看到第一项


任何帮助都会很好。

因为我使用的是
RecyclerView
这不起作用,请参见:

嵌套回收器视图高度不包装其内容

在这两个页面上,人们建议扩展
LinearLayoutManager
并覆盖
onMeasure()

默认情况下,RecyclerView没有包装内容。您必须将RecyclerView与wrap_内容布局管理器一起使用,例如WraplingEarlayoutManager,例如CustomLinearLayoutManager

CustomLinearLayoutManager.java

公共类CustomLinearLayoutManager扩展了LinearLayoutManager{
私有静态最终字符串标记=CustomLinearLayoutManager.class.getSimpleName();
公共CustomLinearLayoutManager(上下文){
超级(上下文);
}
公共CustomLinearLayoutManager(上下文上下文、int方向、布尔反转){
超级(上下文、方向、反转);
}
私有int[]mMeasuredDimension=新int[2];
@凌驾
测量时的公共空隙(RecyclerView.Recycler Recycler,RecyclerView.State State,int widthSpec,int heightSpec){
最终int-widthMode=View.MeasureSpec.getMode(widthmspec);
最终int heightMode=View.MeasureSpec.getMode(heightSpec);
最终int-widthSize=View.MeasureSpec.getSize(widthSpec);
最终int heightSize=View.MeasureSpec.getSize(heightSpec);
整数宽度=0;
整数高度=0;
对于(int i=0;i

}

设置recyclerview项对我很有用。 外包装相对布局是有意添加的,以解决问题
layout\u height=“wrap\u content”
没有 占据通过适配器添加到其中的所有元素的高度。结果被删掉了 初始加载时设备视口外部的项目。 将“RecyclerView”包装为“RelativeLayout”修复了棉花糖设备上的问题

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:descendantFocusability="blocksDescendants">

<android.support.v7.widget.RecyclerView
    android:id="@+id/rv_test"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    tools:listitem="@layout/test_item"></android.support.v7.widget.RecyclerView>
</RelativeLayout>


如何为Recyclerview设置它。在内部Recyclerview setLayoutManager()中,我正在这样做,但索引超出了范围。MyLinearLayoutManager layoutManager=新建MyLinearLayoutManager(主机活动);layoutManager.setOrientation(LinearLayoutManager.VERTICAL);recyclerView.setLayoutManager(layoutManager);我已经更新了布局经理,请调查一下。谢谢你的帮助。此解决方案与Recyclerview 23.1.0版配合使用。
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:descendantFocusability="blocksDescendants">

<android.support.v7.widget.RecyclerView
    android:id="@+id/rv_test"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    tools:listitem="@layout/test_item"></android.support.v7.widget.RecyclerView>
</RelativeLayout>