美文网首页
读取路径下的图片文件,设置为app背景图

读取路径下的图片文件,设置为app背景图

作者: 跟我去北方吧 | 来源:发表于2018-05-11 17:41 被阅读0次
/**
     * 动态设定认证背景图
     */
    private void initBackground() {
        File file = new File(PIC_PATH);
        if(file.exists()){
            Log.e(TAG,"图片:"+PIC_PATH+"存在!切换背景图!");
            try {
                main_background = (FrameLayout) findViewById(R.id.main_background);
                BitmapDrawable drawable = new BitmapDrawable(BitmapFactory.decodeFile(PIC_PATH));
                main_background.setBackground(drawable);
            } catch (Exception e) {
                Log.e(TAG, e.toString());
            }
        }else{
            Log.e(TAG,"图片:"+PIC_PATH+"不存在!使用原背景图!");
        }

    }

相关文章

网友评论

      本文标题:读取路径下的图片文件,设置为app背景图

      本文链接:https://www.haomeiwen.com/subject/wnfqdftx.html