Cole
Cole

Reputation: 2815

Optimizing app background for orientation change?

I have a simple gradient background for my app.

enter image description here

So is there a way to set it so when the orientation is changed from Vertical to Landscape, the background changes to a bigger version of picture (a seperate picture, but same gradient effect)?

Upvotes: 2

Views: 1505

Answers (2)

Shreyash Mahajan
Shreyash Mahajan

Reputation: 23596

You should have to create the another directory as Asanka have said in answer and do it. That solve your issue.

For more information see this.

Enjoy. :)

Upvotes: 0

Asanka Senavirathna
Asanka Senavirathna

Reputation: 4730

say you are using this image as a background in the main.xml layout file. what you have to do is create a new folder in 'res' directory named 'layout-land'

  • create another background image for the landscape mode.
  • copy the main.xml to layout-land directory.
  • set the landscape image as the background for the main.xml in layout-land directory.

now you have two different main.xml files. Android OS will automatically pickup the correct layout according to the orientation.

please note that widgets in patriot main.xml file should exist in landscape main.xml too with the same ID. otherwise you will get nullpointer.

Upvotes: 4

Related Questions