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

/**
     * 动态设定认证背景图
     */
    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背景图)