一:设置全屏
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
super.onCreate(savedInstanceState);//放在这个之前
二:读取SD卡上的图片设为某空间的背景
1:判断是否有SD卡
public static boolean isHaveSDCard(){
String state = Environment.getExternalStorageState();
if(Environment.MEDIA_MOUNTED.equals(state) ||
Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)){
isHaveSdCard = true;
}
return false;
}
2:读取SD卡某个图片
public Drawable setTitleBackgroundFilter(String picName){
BitmapDrawable bd = null ;
if(WelcomePage.isHaveSdCard){
String DrawableSDPath = configUrl.webUiPngPath_sdcard+picName+version+".png"; //configUrl.webUiPngPath_sdcard 是SD路径
bd = new BitmapDrawable(DrawableSDPath);
if(bd != null){
return bd;
}else{
String DrawableMemoryPath = configUrl.webUiPngPath_memory + picName + version + ".png"; //configUrl.webUiPngPath_memory 内存路径
bd = new BitmapDrawable(DrawableMemoryPath);
return bd;
}
}
return null;
}
3:将读取出来的图片设置为相应控件背景,这里是设置为title layout的背景,也可以是各种图片
setContentView(R.layout.froad_main);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE,
R.layout.froad_title);
linearLayoutTitle = (LinearLayout)findViewById(R.id.froad_title_title);
Drawable sld_title = setTitleBackgroundFilter(ResName.titlePng);
if(null != sld_title){
linearLayoutTitle.setBackgroundDrawable(sld_title);
}