I have tried to use
res/layout/my_layout.xml // layout for normal screen size ("default")
res/layout-small/my_layout.xml // layout for small screen size
res/layout-large/my_layout.xml // layout for large screen size
res/layout-xlarge/my_layout.xml // layout for extra large screen size
res/layout-xlarge-land/my_layout.xml // layout for extra large in landscape
When i launch my app it is able to see the res/layout-xlarge/my_layout.xml but when I turn the orientation (the view does turn), it doesn't show the res/layout-xlarge-land/my_layout.xml but the portrait one instead. (sorry for my bad english)
According to the documentation xlarge resolution requires a minimum of 960dp x 720dp
http://developer.android.com/guide/practices/screens_support.html
Since you have only defined a landscape layout for xlarge, it's possible that your device does not have a large enough display to use it.
I would suggest adding
res/layout-small-land/my_layout.xml
res/layout-large-land/my_layout.xml
Additionally you can determine the size category of your device using the answer to this post:
How do I get the ScreenSize programmatically in android
Not all orientations are supported in all versions of the SDK. I could not find the information saying what SDK version xlarge-land is available in but I would bet if you change your minimum SDK version to 16 and target building to 16 it will work. Try going from there and see if you can find when it stops working.
Related: http://developer.android.com/guide/topics/resources/providing-resources.html#Compatibility
Related
I that When starting an android application, android makes a good "guess" as to which layout/drawable to use depending on the screen size. However, I was wondering where it chooses this from? I ask this because I have quite a few layouts which don't all work. I read on the android website that you can make a folder called layout-xhdpi, layout-ldpi... etc. But does android automatically look for layout-xhdpi or layout-ldpi or do I need to specify that anywhere?
Same goes for drawables. When creating a new application in Eclispe it makes automatically drawables folders for you but does this necessarily mean it looks for those.
Conclusion:
Where does android look for alternative screen sizes and how/where can I change that?
Create following layout folder
res/layout/my_layout.xml // layout for normal screen size ("default")
res/layout-small/my_layout.xml // layout for small screen size
res/layout-large/my_layout.xml // layout for large screen size
res/layout-xlarge/my_layout.xml // layout for extra large screen size
res/layout-xlarge-land/my_layout.xml // layout for extra large in landscape orientation
res/drawable-mdpi/my_icon.png // bitmap for medium density
res/drawable-hdpi/my_icon.png // bitmap for high density
res/drawable-xhdpi/my_icon.png // bitmap for extra high density
I'm looking to make an Android app that changes the look of the UI based on the device it's shown on (4 inch phone, 7inch tablet and 10inch tablet). I know you have the fragments API and it's probably that which I should use for this, but all the examples I've seen just have 2 activities sitting side by side and the code is a bit OTT for my needs (they have events passing between them etc).
Here is the comparison between a 4 inch device and a 7 inch device and how the different UI elements should move around (also note that element A can change design between the two devices).
Any ideas on how I would go about doing this, or if anyone has any sample code that would be fantastic!
I think you should probably design different xml for each size. You can use the qualifier in the layout dir for different screen size. http://developer.android.com/guide/topics/resources/providing-resources.html#AliasResources
You can use different directory for different size :
res/layout/my_layout.xml // layout for normal screen size ("default")
res/layout-small/my_layout.xml // layout for small screen size
res/layout-large/my_layout.xml // layout for large screen size
res/layout-xlarge/my_layout.xml // layout for extra large screen size
res/layout-xlarge-land/my_layout.xml // layout for extra large in landscape orientation
res/drawable-mdpi/my_icon.png // bitmap for medium density
res/drawable-hdpi/my_icon.png // bitmap for high density
res/drawable-xhdpi/my_icon.png // bitmap for extra high density
and for more information :
http://developer.android.com/guide/practices/screens_support.html
Good Luck,,, :D
See also Fragments for Android 3.0+.
I have a question for you guys about multiple screens.
I am testing an Android application for different-sized screens using emulator. The application have been initially developed for resolution 320*480. I know it is not good and I have problems in my code. Moreover, I have used pixels in some places of code instead of dip. You see, I am not a professional in Android. In any case, there is no problem for devices with resolution 320*480 and 480*800. For the second one the application looks stretched. According to documentation it should be so. But, when I am trying resolutions 540*960 or 1024*600 the application occupies just a part of screen and it seems to be 320*480. The question is: why it didn't stretched the application to the whole screen? How can I do it?
I have read Supporting Multiple Screens guide here: http://developer.android.com/guide/practices/screens_support.html#dips-pels, but I haven't found an answer for my question.
Have you go through this lines in the link given by you?
res/layout/my_layout.xml // layout for normal screen size ("default")
res/layout-small/my_layout.xml // layout for small screen size
res/layout-large/my_layout.xml // layout for large screen size
res/layout-xlarge/my_layout.xml // layout for extra large screen size i
res/layout-xlarge-land/my_layout.xml // layout for extra large in landscape orientation
res/drawable-mdpi/my_icon.png // bitmap for medium density
res/drawable-hdpi/my_icon.png // bitmap for high density
res/drawable-xhdpi/my_icon.png // bitmap for extra high density
for different size devices, make different folder as given above like layout-small,layout-large.. and put your designing xml in that.
Hope this help you.
I have developed an android application, which only supports portrait orientation, for android phones. Now, I need to modify this app because I want to do the universal version (for tablets, too) but I have a problem. The phone version only supports portrait orientation and the tablet version supports portrait and landscape orientations. Is there any way to define different orientations for tablets and phones?
Thanks
I believe you can create a subfolder in the res/layout folder, called xlarge-land and xlarge-port with the xml files in them. the device itself will know what xml to load.
res/layout/my_layout.xml // layout for normal screen size ("default")
res/layout-small/my_layout.xml // layout for small screen size
res/layout-large/my_layout.xml // layout for large screen size
res/layout-xlarge/my_layout.xml // layout for extra large screen size
res/layout-xlarge-land/my_layout.xml // layout for extra large in landscape orientation
resource: http://developer.android.com/guide/practices/screens_support.html
I am making an app that is readily available and MOSTLY used on phones, but would be CONVENIENT to use on a tablet if available.
I am familiar with landscape/portrait layouts for the separate XML files, but what about for the different resolutions? This is also an issue for phone-only applications, what is the best way to have scalable layouts.
I use the dip values which are density independent but not as effective as just using percentages that will scale your layout effectively.
I also hardcode the XML. I IMAGINE that I could programmatically generate the layout by checking the screen width and height ON EVERY ACTIVITY, but tell me there is a better way?
You can provive extra layouts by specifying the screen size (small, normal, large and xlarge) in the same way you specify layouts for portrait or landscape.
These are some examples taken from the android documentation related to this subject
res/layout/my_layout.xml // layout for normal screen size ("default")
res/layout-small/my_layout.xml // layout for small screen size
res/layout-large/my_layout.xml // layout for large screen size
res/layout-xlarge/my_layout.xml // layout for extra large screen size
res/layout-xlarge-land/my_layout.xml // layout for extra large in landscape orientation
The book The Busy Coder's Guide to Android Development has an excellent explanation about this subject.