隨筆 - 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
          主站蜘蛛池模板: 沙河市| 璧山县| 绿春县| 交口县| 垫江县| 茂名市| 扶余县| 梁山县| 太原市| 乌兰浩特市| 武义县| 岳池县| 土默特右旗| 自治县| 阿瓦提县| 尤溪县| 东海县| 柘荣县| 山阳县| 互助| 舟曲县| 保定市| 历史| 梁平县| 济宁市| 阳曲县| 庆城县| 衡东县| 泾源县| 珠海市| 灵石县| 广州市| 彩票| 公安县| 澳门| 罗平县| 钦州市| 河曲县| 阳西县| 炉霍县| 元江|