Layout Earth does not select xml terrain layout

I want to have a different layout for the landscape and portrait. But both orientations end up using the same xml layout. I ran into over a dozen questions at StackOverflow, but none of them solve my problem.

In the layouts there is a file activity_main.xml . I have folders for different terrain layouts, as indicated in this :

 layout/ activity_main.xml layout-land-hdpi/ activity_main.xml layout-land-ldpi/ activity_main.xml layout-land-mdpi/ activity_main.xml layout-small-land-ldpi/ activity_main.xml 

They have the same activity_main.xml file, except that the background color is different.

I do not have android:configChanges installed in AndroidManifest.xml for Activity. I do not override onConfigurationChanged() since I do not manually deal with orientation changes.

I use the actionbarsherlock library in the project. I created action-style themes using the ActionBar Sytele Generator .

minSdk and TargetSdk from AndroidManifest.xml:

 <uses-sdk android:minSdkVersion="10" android:targetSdkVersion="17" /> 

I run the code on emulators running Android 4.3 (Galaxy Nexus), Android 4.2.2 (Nexus 7) and Android 2.3.3 (Nexus S). The result is the same.

Is there something that I am not doing right?

Thanks!

+4
source share
3 answers

You are doing it wrong. The layout and layout-land folders must be at the same level.

You need res/layout and res/layout-land .

 res |_ layout |_ layout-land |_ layout-... |_ layout-... 

So your setup should look like this:

 res |_ layout |_ activity_main.xml |_ layout-land-hdpi |_ activity_main.xml |_ layout-land-ldpi |_ activity_main.xml |_ layout-land-mdpi |_ activity_main.xml |_ layout-small-land-ldpi |_ activity_main.xml 
+5
source

You should define the entire layout folder in the res folder instead of the layout folder this way:

res/layout-land

not the way you did how

 res/layout/layout-land 
+1
source

Maybe your phone’s screen density is xhdpi, for which you did not save the folder. Also save the folder for layout-land-xhdpi and try. You must also save layout-land-xxhdpi.

Or you can just have a layout of the earth

0
source

Source: https://habr.com/ru/post/1496490/


All Articles