0
votes

i have already posted my issue in SO and got an answer but i have a problem in that too

my former question is "i have created a quiz game in my app. The game is to be played in portrait mode. After the game gets over the score is been calculated and its been showed in the score page when i click ok a pop up window appears and asks for the name. I have placed an option to share the result in facebook and twitter.

now when i enter the name and click ok, a page with score name and share button appears, if i click share it moves into facebook or the other, but if i change over to landscape mobe my app gets crashed."

i got a solution to add a line in manifest file

 <activity android:name=".main" 
        android:configChanges="orientation" />

along with the following code in the class file

@Override
public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); }

This answer helps me to move to next operation without crashing my app but the problem is when i change from landscape to portrait, the background image and text also gets changed to portrait and half the screen the seems to be a blank one and text or not appearing fully.

this is the same when changed from landscape to orientation. i want the image and text to be fitted to proper orientation.

this problem has not occured before entering those manifest and coding lines

pls give me a solution.

1
Can we see code? Specifically the line you added to your manifest and possibly the XML of your layout that you are having issues with?Corey Sunwold
<activity android:name=".main" android:configChanges="orientation" /> along with the following code in the class file @Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); }Siva K

1 Answers

1
votes

You could try an explicit definition of your layouts.

For example have two layout files, one for landscape and another for portrait. Android is intelligent enough to use the best available layout -> Read HERE

To handle screen orientation gracefully there is something more you need to do -> Read HERE