Mohammad Reza Majid Pour Mohammad Reza Majid Pour - 27 days ago 9
Android Question

how to disable rotate in android ? how to add sensor portrait to manifest ? how to fix layout in landspace?

i know its a noob question but i am new in android development and i dont want my app rotate in landspace.
according to some of questions i found sensor portrait. i tried to add it in manifest but i dont know where.
if its not working is there any source code to disable rotate?
i am really need help my layout looks owful in landspace.
i dont know how to fix the background
what can i do to fix layout in landspace?
what should i do?
i didnt find the answer in question.
thanks


  1. How to use sensorportrait?

  2. source code for disable rotate?

  3. fix layout in landspace?



i really dont want the answer for thirdone but its a good point for a app to work in portrait and landspace.

Answer

Take a look at this document, it explains each property in your AndroidManifest.xml. https://developer.android.com/guide/topics/manifest/activity-element.html

  1. How to use sensorportrait?

    These Properties are defined in your AndroidManifest.xml file.

    android:screenOrientation=["unspecified" | "behind" | "landscape" | "portrait" | "reverseLandscape" | "reversePortrait" | "sensorLandscape" | "sensorPortrait" | "userLandscape" | "userPortrait" | "sensor" | "fullSensor" | "nosensor" | "user" | "fullUser" | "locked"]

  2. source code for disable rotate?

    In your AndroidManifest.xml file, where you define "activity", u set orientation you support as defined above.

  3. fix layout in landspace?

    You can have different layout for your activity in landscape mode. for this simply create layout-land folder parallel to layout folder in res. e.g. if you have activity_main.xml in layout folder, create another activity_main.xml in layout-land folder. You can move stuff around as you wish. Note: I would reccomend you take a look at Fragments, this might help you on what you are trying to achieve. https://developer.android.com/guide/components/fragments.html

Comments