I recently started creating apps for android and wanted to test layouts for different screen sizes. Since I’ve got no android device I created to virtual ones with AVD:
- 240 dpi, No width or height specifications (for phones)
- 160 dpi, 800 x 1280 (for tablets)
Since I just finished a tutorial I just edited my app so that the directory looks like this:
res/
layout/
activity_main.xml
layout-large/
activity_main.xml
layout/activity_main.xml:
<?xml ...>
<LinearLayout ...>
<Button
android:text="@string/button_send"
... />
</LinearLayout>
layout-large/activity_main.xml:
<?xml ...>
<LinearLayout ...>
<Button
android:text="@string/button_send_large"
... />
</LinearLayout>
The two different string ressources contain different strings, so what I expected it to do is to display the one on large displays and the other on everything else. What it does is just using the .xml file from the “layout” folder on any device.
So I did some research and tried to rename “layout-large” to “layout-xlarge” and finally to “layout-sw600dp”. Didn’t work either.
Both devices run on Android 4.1.
And yes, I did make sure that eclipse launched the app on the correct device.
Question: What am I doing wrong?
Put followin
in res/ layout/ activity_main.xml
AND CREATE
res/ layout-hdpi/ activity_main.xml
Put followin
in res/ layout-hdpi/ activity_main.xml