【Android】问题记录

这篇博客总结了Android开发中遇到的一些问题及其解决方案,包括RecyclerView的divider设置、BitmapDrawable转换、图片加载优化、Dialog布局限制、物理按键监听、系统栏透明设置以及RecyclerView的预加载策略,提供了相应的代码片段和库的推荐。
摘要由CSDN通过智能技术生成

1.RecyclerView设置divider:
链接
代码方法的话比较麻烦,如果只是想设置简单的divider,直接在item的layout里画一条线就可以了

2.BitmapDrawable from TransitionDrawable

android.graphics.drawable.TransitionDrawable cannot be cast to android.graphics.drawable.BitmapDrawable
链接
//in this case your solution would be right, one can just cast it, //but if not (and that is your case) one needs to do something like //that:


private Bitmap getBitmap(Drawable icon) {
        Bitmap result;
        if (icon instanceof BitmapDrawable) {
            result = ((BitmapDrawable) icon).getBitmap();
        } else {
            Bitmap bitmap = Bitmap.createBitmap(icon.getIntrinsicWidth(), icon.getIntrinsicHeight(), Config.ARGB_8888);
            Canvas canvas = new Canvas(bitmap);
            icon.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
            icon.draw(canvas);
            result = bitmap;
        }
        return result;
    }

3.RecyclerView 加载url图片,平滑滚动的问题: Glide开源项目
listview 为了保持图片位置不错乱,需要setTag;
改用recycler后,从volley换到glide

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值