androidlayoutonconfigurationchangedandroid-configchanges

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?


Solution

  • 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.