Hide StatusBar/Title on QVGA - Getting Screen Resolution
What you learn: You will learn how to get the screen-resolution and hide the statusbar on QVGA-reoslutions (or whatever you want).
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
final Window win = getWindow();
final int screenHeight = win.getWindowManager().getDefaultDisplay().getHeight();
final int screenWidth = win.getWindowManager().getDefaultDisplay().getWidth();
if((screenHeight == 320 && screenWidth == 240) || (screenHeight == 240 && screenWidth == 320)){
// No Statusbar
win.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
// No Titlebar
requestWindowFeature(Window.FEATURE_NO_TITLE);
requestWindowFeature(Window.FEATURE_PROGRESS);
}
setContentView(R.layout.mylayout);
//... Your Code here ...
}
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
final Window win = getWindow();
final int screenHeight = win.getWindowManager().getDefaultDisplay().getHeight();
final int screenWidth = win.getWindowManager().getDefaultDisplay().getWidth();
if((screenHeight == 320 && screenWidth == 240) || (screenHeight == 240 && screenWidth == 320)){
// No Statusbar
win.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
// No Titlebar
requestWindowFeature(Window.FEATURE_NO_TITLE);
requestWindowFeature(Window.FEATURE_PROGRESS);
}
setContentView(R.layout.mylayout);
//... Your Code here ...
}
原帖: http://www.anddev.org/hide_statusbar-title_on_qvga_-_getting_screen_resolution-t2689.html
转载于:https://blog.51cto.com/liushen/157097