Kamran Omar
Kamran Omar

Reputation: 1887

change orientation without onCreate call

i want to change layout without calling the onCreate method. i also define android:configChanges="orientation|keyboardHidden" in my activity and it is not calling the onCreate method but the layout not adjust appropriately on landscape mode.

my current layout look like as follows.

alt text

after change orientation as landscape it look like as follows: alt text

but on landscape i want the following result.

alt text

is there any auto adjacent property?

how can i do it?

Upvotes: 6

Views: 11022

Answers (6)

Gus Arik
Gus Arik

Reputation: 349

Put this in your manifest bro..

android:configChanges="orientation|keyboardHidden|screenSize|uiMode"

It's solve your and my problem :D

Upvotes: 0

nil_born to hack
nil_born to hack

Reputation: 11

You only put this android:configChanges="orientation|keyboardHidden" in your activity tag in android manifest.it works.

Upvotes: 0

ThuVN
ThuVN

Reputation: 11

You could add android:configChanges="orientation" to Activity tag on AndroidManifest.xml. Try it.

Upvotes: 1

GSree
GSree

Reputation: 2898

See this documentation th handle this

http://developer.android.com/resources/articles/faster-screen-orientation-change.html

Upvotes: 1

krunal shah
krunal shah

Reputation: 16339

there is no auto adjust property while view changes from portrait to landscape.

For images that you want to display in landscape mode

Create one filename.xml file and design your layout for landscape mode. Give filename same as your previous xml file in layout folder that you are using for activity.

Create folder in res/ name as layout-land and then keep that filename.xml file in res/layout-land folder

It will automatically call that res/layout-land/filename.xml when orientation changes from portrait to landscape.

Or you can also use

    @Override
    public void onConfigurationChanged(Configuration newConfig) {

      super.onConfigurationChanged(newConfig);

      if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
          //your code
      } else if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
         //your code
      }
    }

Upvotes: 4

IronFerret
IronFerret

Reputation: 21

I'm going to assume you're using a LinearLayout, because you didn't specify, but there's a function in the LinearLayout class called setOrientation() that should fix this. You'll have to create an instance of your layout in your java file (which you may have already done) and then create either an orientationchange or resize event listener on your window. After that it's just changing the orientation to horizontal/vertical based on screen orientation.

Upvotes: 0

Related Questions