引用:http://www.cnblogs.com/miaoshuncai/articles/2170362.html

getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);//设置成全屏模式

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE););//强制为横屏

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);//竖屏

我做的东西里面还用到了去掉标题栏。
我也贴出来
requestWindowFeature(Window.FEATURE_NO_TITLE);

垂直居中:

android:layout_centerVertical="true"

水平居中:

android:layout_centerHorizontal="true"

1.hideStatusbarAndTitlebar()隐藏statusbar和titlebar.

?
1 2 3 4 5 6 7 8 private void hideStatusbarAndTitlebar() { final Window win = getWindow(); // No Statusbar win.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); // No Titlebar requestWindowFeature(Window.FEATURE_NO_TITLE); }

2.设置屏幕显示模式ScreenOrientation.

在activity里设置android:screenOrientation的值。
android:screenOrientation的属性有以下值:
unspecified(默 认值,由系统判断状态自动切换),The default value. The system chooses the orientation. The policy it uses, and therefore the choices made in specific contexts, may differ from device to device.
landscape,横屏
portrait,竖屏
user(用户当前设置的orientation值),The user's current preferred orientation.
behind(下一个要显示的Activity的orientation值),The same orientation as the activity that's immediately beneath it in the activity stack.
sensor(传 感器的方向),The orientation determined by a physical orientation sensor. The orientation of the display depends on how the user is holding the device; it changes when the user rotates the device.
nosensor(不 使用传感器,这个效果差不多等于unspecified).An orientation determined without reference to a physical orientation sensor. The sensor is ignored, so the display will not rotate based on how the user moves the device. Except for this distinction, the system chooses the orientation using the same policy as for the "unspecified" setting.

3.水平/垂直居中的方法.

设置parent的android:gravity为"center"。

4.获得当前屏幕宽高的方法.

? 去标题this.requestWindowFeature(Window.FEATURE_NO_TITLE); 要在setContentView(...)之前用

更多相关文章

  1. android通过反射来获取系统属性SystemProperties
  2. android 创建添加快捷方式
  3. Android(安卓)全屏无标题详解
  4. Android实现界面跳转
  5. android webview设置自适应任意大小的pc网页
  6. Android(安卓)去掉title bar的3个方法
  7. Android(安卓)RingtoneManager铃声管理
  8. Android中设置全屏的方法
  9. android之渐变色背景

随机推荐

  1. Android(安卓)中读取Excel文件实例详解
  2. Android基于Pull方式解析xml的方法详解
  3. android中采用Pull解析XML文档
  4. “哎哟!蛮吊的” 之 Android(安卓)BroadCa
  5. android 定位的4种方式介绍
  6. android interview 2
  7. 完美解决Android中,ScrollView嵌套ListVie
  8. Android中通过AsyncTask类来制作炫酷进度
  9. 利用 CMake 和 NDK 交叉编译 Android(安
  10. Android(安卓)通过广播监听USB连接状态的