RecycleView 不显示、显示不全及滑动卡顿

简介: RecycleView 出现的不显示或显示不全。ScrollView中嵌套RecycleView滑动出现卡顿。

RecycleView 出现的不显示或显示不全。


1.<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
    <android.support.v7.widget.RecyclerView
        android:id="@+id/mrc_protocols"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="@dimen/mdp_10"
        android:layout_marginRight="@dimen/mdp_12"
        android:divider="@null"
        android:scrollbars="none" />
</RelativeLayout>


ScrollView中嵌套RecycleView滑动出现卡顿


LinearLayoutManager linearLayoutManager = new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false) {
    @Override
    public boolean canScrollVertically() {
        return false;
    }
};
//初始化视图
mrcProtocols.setLayoutManager(linearLayoutManager);


自动滚动到中间


ScrollView顶部子控件加下面这2个属性

android:focusable="true"

android:focusableInTouchMode="true"

他就不会自动滚动到中间了


<ScrollView
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:focusable="true"
            android:focusableInTouchMode="true"
            android:text="顶部控件" />
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="一堆控件" />
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="两堆控件" />
    </LinearLayout>
</ScrollView>


布局不能撑满全屏


       Android 使用ScrollView属性fillViewport解决android布局不能撑满全屏。


       使用了ScrollView 嵌套 LinearLayout时,在大屏幕手机如三星note3手机上下面会留白,问题的解决办法是在第一层LinearLayout里面嵌套多个LinearLayout,最重要的是将ScrollView中android:fillViewport设置为true。


       当ScrollView里的元素想填满ScrollView时,使用”fill_parent”是不管用的,必需为ScrollView设置:android:fillViewport=”true”。


       当ScrollView没有fillVeewport=“true”时, 里面的元素(比如LinearLayout)会按照wrap_content来计算(不论它是否设了”fill_parent”),而如果LinearLayout的元素设置了fill_parent,那么也是不管用的,


       因为LinearLayout依赖里面的元素,而里面的元素又依赖LinearLayout,这样自相矛盾.所以里面元素设置了fill_parent,也会当做wrap_content来计算。


相关推荐


Android RecyclerView的Adapter和ViewHolder

相关文章
|
XML 前端开发 Android开发
滑动开关按钮SlideSwich
iphone上有开关控件,很漂亮,其实android4.0以后也有switch控件,但是只能用在4.0以后的系统中,这就失去了其使用价值,而且我觉得它的界面也不是很好看。最近看到了百度魔拍上面的一个控件,觉得很漂亮啊,然后反编译了下,尽管没有混淆过,但是还是不好读,然后就按照自己的想法写了个,功能和百度魔拍类似。 下面是百度魔拍的效果和SlideSwitch的效果
1345 0
|
C# 定位技术 API
WPF技术触屏上的应用系列(五): 图片列表异步加载、手指进行缩小、放大、拖动 、惯性滑入滑出等效果
原文: WPF技术触屏上的应用系列(五): 图片列表异步加载、手指进行缩小、放大、拖动 、惯性滑入滑出等效果         去年某客户单位要做个大屏触屏应用,要对档案资源进行展示之用。
1250 0
|
前端开发
CSS实现鼠标移动到图片或按钮上缓慢变大,添加过渡动画效果,自定义动画时间
CSS实现鼠标移动到图片或按钮上缓慢变大,添加过渡动画效果,自定义动画时间
2247 0
|
iOS开发
【iOS开发】UIScrollView 看不到内容、UIScrollView 不能滑动
初学者第一次使用 UIScrollView 的时候,很可能会遇到 UIScrollView 滑动不了,或者明明添加了内容,却看不到的问题。 这里展示最简洁、最常态化的一种在 UIScrollView 中添加可以滑动的 UIImageView 的案例。
831 0
|
Android开发 数据格式 XML
精确监听ListView滑动到底部
main.xml如下: listviewitem.mxl如下: MainActivity如下: import java.
729 0
|
9月前
|
弹性计算 运维 Shell
显示进度条(回旋镖版)
【4月更文挑战第29天】
47 0

热门文章

最新文章