recycleview和scrollive的配合使用,在6.0以下正常使用。在6.0上高度显示不全的问题

来源:互联网 发布:java上线项目 编辑:程序博客网 时间:2024/05/18 22:15
直接在recycleview加一层相对布局就可以了
 <RelativeLayout                android:layout_width="match_parent"                android:layout_height="wrap_content"                android:descendantFocusability="blocksDescendants">                <android.support.v7.widget.RecyclerView                    android:id="@+id/menuRv"                    android:layout_width="match_parent"                    android:layout_height="wrap_content"                    android:layout_marginLeft="@dimen/margin_16"                    android:layout_marginRight="@dimen/margin_16">                </android.support.v7.widget.RecyclerView>                </RelativeLayout>
关键代码是android:descendantFocusability="blocksDescendants"

该属性是当一个为view获取焦点时,定义viewGroup和其子控件两者之间的关系。

属性的值有三种:

beforeDescendants:viewgroup会优先其子类控件而获取到焦点

afterDescendants:viewgroup只有当其子类控件不需要获取焦点时才获取焦点

blocksDescendants:viewgroup会覆盖子类控件而直接获得焦点
0 0
原创粉丝点击