android 横竖屏等设置
来源:互联网 发布:站长域名查询 编辑:程序博客网 时间:2024/05/21 06:23
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.
private void hideStatusbarAndTitlebar() {final Window win = getWindow();// No Statusbarwin.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);// No TitlebarrequestWindowFeature(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.获得当前屏幕宽高的方法.
Display display = getWindowManager().getDefaultDisplay();Config.screenWidth = display.getWidth();Config.screenHeight = display.getHeight();
- android 横竖屏等设置
- Android Activity 常用功能设置(全屏、横竖屏等)
- 【Android】 Activity 常用功能设置(全屏、横竖屏等)
- Android Activity 常用功能设置(全屏、横竖屏等)
- Android Activity 常用功能设置(全屏、横竖屏等)
- Android Activity 常用功能设置(全屏、横竖屏等)
- Android Activity 常用功能设置(全屏、横竖屏等)
- Android Activity 常用功能设置(全屏、横竖屏等)
- Android Activity 常用功能设置(全屏、横竖屏等)
- Android Activity 常用功能设置(全屏、横竖屏等)
- android设置横竖屏、可触控、获取分辨率等代码
- Android横竖屏设置
- android 横竖屏设置
- ANDROID 设置横竖屏
- Android横竖屏设置
- Cocos2dx android 横竖屏设置!
- Android横竖屏的设置
- Android如何设置横竖屏
- SGU 171 Sarov zones【贪心】
- 旧事重提——函数的指针传值
- 相约世纪末
- COM编程入门:第一部分 什么是COM,如何使用COM
- boost asio 需要使用智能指针而不能使用普通指针的原因
- android 横竖屏等设置
- Flash - textarea组件的背景边框设置
- Deverpress之TreeList、Grid
- Android禁止横屏竖屏切换
- linux下的g++编译器安装
- Hadoop Combiner 操作
- 伸长的守候
- php+mysql+apache环境搭建
- 【phpcms-v9】如何实现在含有子栏目的栏目下添加内容?