Pumpkin
Pumpkin

Reputation: 2033

Android - How to stop screen adaptation to rotation

I am a newbie to the android world, and as of today I completed my first application.

I test my work on a physical device, and quite recently it has came to my attention that whenever I turn/rotate my device, my application tries to adapt itself to the new resolution 800x400.

Since I have designed the whole app for 400x800 resolution, this change messes up the original design, as well as sending a new call to "onCreate" method of the last activity it was on, before turning/rotating the device.

I would like to learn whether it is possible or not, or which class I should use to stop the adaption to resolution.

Upvotes: 0

Views: 694

Answers (1)

Krylez
Krylez

Reputation: 17800

This line (in AndroidManifest.xml) will lock the activity in portrait mode:

<activity android:name="MyActivity"
    android:screenOrientation="portrait" />

There are things that you can do to make your layouts work well in different orientations and resolutions, such as using dips instead of pixels to measure your views.

When you have time, consider making layout files for landscape mode. Create a "layout-land" directory within your res directory and drop he landscape layout files there, using the exact same file names for their portrait counterparts.

Upvotes: 3

Related Questions