Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Layout land not working

I've been looking at issues in stackoverflow and I've tried everything I've seen but the layout-land not work. In my code I have and the method onConfigurationChanged

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

And the manifest file:

<activity
        android:name="com.sde.PlayerTrack"
        android:theme="@style/AppTheme"
        android:configChanges="orientation|keyboardHidden|screenSize"
        >
    </activity>

I tried also to remove in the android manifest entry: configChanges and then the layout land load but the components i have (TextView, scrollbar ...) does not work properly.

Can you help me, please?

like image 800
Garmael Avatar asked Mar 18 '14 10:03

Garmael


2 Answers

Remove orientation from the android:configChanges in your manifest file, and put you landscape layout xml file into layout-land folder.

like image 200
Cheerag Avatar answered Sep 27 '22 21:09

Cheerag


Finally, my solution is:

AndroidManifest.xml File:

<activity
        android:name="activity.name"
        android:configChanges="orientation|keyboardHidden|screenSize"       
        >

And in the activity implement the method onConfigurationChanged (Configuration newconfig):

@Override
 public void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);     
        if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
            createHorizontalalLayout();            
        } else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT){
            createVerticalLayout();             
        }
}

With createVerticalLayout () and createHorizontalLayout () programmatically do the layouts.

like image 36
Garmael Avatar answered Sep 27 '22 22:09

Garmael