发布于 2016-03-18 04:37:44 | 198 次阅读 | 评论: 0 | 来源: 网友投递

这里有新鲜出炉的精品教程,程序狗速度看过来!

Android移动端操作系统

Android是一种基于Linux的自由及开放源代码的操作系统,主要使用于移动设备,如智能手机和平板电脑,由Google公司和开放手机联盟领导及开发。尚未有统一中文名称,中国大陆地区较多人使用“安卓”或“安致”。


这篇文章主要介绍了Android实现固定屏幕显示的方法,实例分析了Android屏幕固定显示所涉及的相关技巧,具有一定参考借鉴价值,需要的朋友可以参考下

本文实例讲述了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开发中的屏幕固定问题就解决了!


<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程序设计有所帮助。



最新网友评论  共有(0)条评论 发布评论 返回顶部

Copyright © 2007-2017 PHPERZ.COM All Rights Reserved   冀ICP备14009818号  版权声明  广告服务