i want to make my application only in landscape in android

前端 未结 5 573
Happy的楠姐
Happy的楠姐 2020-12-08 02:19

I want to make my app work only in landscape mode but can\'t make it work. I have given screenOrientation = \"landscape\" even though the first page will be in

相关标签:
5条回答
  • 2020-12-08 02:34

    You can also try setting the orientation from your code

    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    

    Check this link for more info

    http://www.devx.com/wireless/Article/40792/0/page/5

    0 讨论(0)
  • 2020-12-08 02:38

    Keep this part of the manifest as it already is. For example, consider the IntroHome activity.

    <activity android:name=".IntroHome"
               android:label="@string/app_name"
               android:screenOrientation="landscape"  
               >
    </activity>
    

    And for the activity XML, make sure you have the IntroHome activity layout XML only in the layout-land folder. This way, the activity / activities you have will only show the the landscape version of the XML that you have defined.

    0 讨论(0)
  • 2020-12-08 02:38

    Try adding:

    android:configChanges="orientation|keyboardHidden"
    

    Let me know if it helps!! Just a guess!!

    0 讨论(0)
  • This looks like an old post, but it looks to me like if you set the mode to landscape in the manifest file, and then switch the mode to landscape in the java code, you might be switching the mode twice causing the device to render in portrait mode instead. Try commenting out the code in your java file and see what happens. If it doesn't work all you have to do is change it back. Easy peasy test.

    0 讨论(0)
  • 2020-12-08 02:43

    You can use following code as per requirement:

    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); and setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

    you have to put these code before setContentView(R.layout.layout_name.xml).

    0 讨论(0)
提交回复
热议问题