隨筆 - 0, 文章 - 264, 評論 - 170, 引用 - 0
          數據加載中……

          關于Android橫豎屏切換的解決方法

          在開發游戲的時候,有些 游戲是只能橫屏玩的,所以手機豎立放置的時候,要保持游戲畫面依然橫屏。要做到這個要求其實很簡單,在AndroidManifest.xml里面配置一 下就可以了。加入這一行android:screenOrientation="landscape"。

          例如(landscape是橫向,portrait是縱向):

          <?xml version="1.0" encoding="utf-8"?>  
          <manifest xmlns:android="http://schemas.android.com/apk/res/android"  
          #       
          package="com.ray.linkit"  
          #       android:versionCode
          ="1"  
          #       android:versionName
          ="1.0">  
          #     
          <application android:icon="@drawable/icon" android:label="@string/app_name">  
          #         
          <activity android:name=".Main"  
          #                   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>  
          #                 
          <activity android:name=".GamePlay"  
          #                 android:screenOrientation
          ="portrait"></activity>  
          #                 
          <activity android:name=".OptionView"  
          #                 android:screenOrientation
          ="portrait"></activity>  
          #     
          </application>  
          #     
          <uses-sdk android:minSdkVersion="3" /> 
          </manifest> 


          另外,android中每次屏幕的切換動會重啟Activity,所以應該在Activity銷毀前保存當前活動的狀態,在Activity再次Create的時候載入配置,那樣,進行中的游戲就不會自動重啟了!

          posted on 2010-11-29 23:25 小一敗涂地 閱讀(1848) 評論(1)  編輯  收藏 所屬分類: android+移動開發

          評論

          # re: 關于Android橫豎屏切換的解決方法  回復  更多評論   

          嗯,小的細節,大的事業!
          2011-08-31 17:23 | Hua Hero
          主站蜘蛛池模板: 兴仁县| 铜梁县| 广平县| 汝城县| 尤溪县| 吉林省| 石家庄市| 旬邑县| 勃利县| 蒙阴县| 西昌市| 安塞县| 绥江县| 宜黄县| 延津县| 新郑市| 建瓯市| 蚌埠市| 平乡县| 印江| 三穗县| 高密市| 临潭县| 襄樊市| 平乡县| 田林县| 顺平县| 云阳县| 西城区| 兴安县| 静乐县| 永春县| 旬邑县| 新昌县| 青川县| 新竹县| 永年县| 葫芦岛市| 永嘉县| 正阳县| 内乡县|