0
点赞
收藏
分享

微信扫一扫

八天 自定义控件 使用贴图加载图片非原图片大小 decodeResource

Ichjns 2022-03-11 阅读 85

使用自定义方法

mBmpDial = decodeResource( getResources(),
                R.drawable.android_clock_dial );

private Bitmap decodeResource(Resources resources, int id) {
        TypedValue value = new TypedValue();
        resources.openRawResource( id, value );
        BitmapFactory.Options opts = new BitmapFactory.Options();
        opts.inTargetDensity = value.density;//获取当前手机运行环境的手机密度
        opts.inScaled = false;
        return BitmapFactory.decodeResource( resources, id, opts );
    }

``

举报

相关推荐

0 条评论