本文实例讲述了Android实现固定屏幕显示的方法。分享给大家供大家参考。具体如下:
在Android开发中我们会碰到开发屏幕扭转的情况,如何固定住屏幕ScreenOrientation 呢?
在学习jetboy代码时,发现屏幕被旋转了,代查代码没有找到相关设置,在manifest.xml中找到了相关的代码:
找到这名代码:
复制代码 代码如下:
android:screenOrientation="portrait"
portrait表示横向,landscape表示纵向
如果要使Activity的View界面全屏,只需要将最上面的信号栏和Activity的Title栏隐藏掉即可,隐藏Title栏的代码:
复制代码 代码如下:
requestWindowFeature(Window.FEATURE_NO_TITLE);
配置文件里代码:
复制代码 代码如下:
android:theme="@android:style/Theme.NoTitleBar"
隐藏信号栏的代码:
复制代码 代码如下:
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
其它使用:
复制代码 代码如下:
getWindow().setFlags(WindowManager.LayoutParams.TYPE_STATUS_BAR, WindowManager.LayoutParams.TYPE_STATUS_BAR);
至此Android开发中的屏幕固定问题就解决了!
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
< manifest xmlns:android = "http://schemas.android.com/apk/res/android"
package = "com.example.android.jetboy" android:versionCode = "1"
android:versionName = "1.0.0" >
< application android:icon = "@drawable/icon"
android:label = "@string/app_name"
android:theme = "@android:style/Theme.NoTitleBar" >
< activity android:name = ".JetBoy"
android:label = "@string/app_name"
android:screenOrientation = "portrait"
>
< intent-filter >
< action android:name = "android.intent.action.MAIN" />
< category
android:name = "android.intent.category.LAUNCHER" />
</ intent-filter >
</ activity >
</ application >
< uses-sdk android:minSdkVersion = "4" ></ uses-sdk >
<!--
<uses-library android:name="android.test.runner" />
<instrumentation
android:name="android.test.InstrumentationTestRunner"
android:targetPackage="com.example.android.jetboy"
android:functionalTest="true" android:label="Jetboy Test All Runner"/>
<uses-permission android:name="android.permission.RUN_INSTRUMENTATION"/>
-->
</ manifest >
< manifest xmlns:android = "http://schemas.android.com/apk/res/android"
package = "com.example.android.jetboy" android:versionCode = "1"
android:versionName = "1.0.0" >
< application android:icon = "@drawable/icon"
android:label = "@string/app_name"
android:theme = "@android:style/Theme.NoTitleBar" >
< activity android:name = ".JetBoy"
android:label = "@string/app_name"
android:screenOrientation = "portrait"
>
< intent-filter >
< action android:name = "android.intent.action.MAIN" />
< category
android:name = "android.intent.category.LAUNCHER" />
</ intent-filter >
</ activity >
</ application >
< uses-sdk android:minSdkVersion = "4" ></ uses-sdk >
<!--
<uses-library android:name="android.test.runner" />
<instrumentation
android:name="android.test.InstrumentationTestRunner"
android:targetPackage="com.example.android.jetboy"
android:functionalTest="true" android:label="Jetboy Test All Runner"/>
<uses-permission android:name="android.permission.RUN_INSTRUMENTATION"/>
-->
</ manifest >
|
希望本文所述对大家的Android程序设计有所帮助。