问题
I created my application in only one layout. but now I need to support high resolution screens. I have a ListView
getting images from JSON
.
android:layout_width="fill_parent"
android:layout_height="174dp"
Images are shown good size on 4 inch device, but on tablet images are cropped from top and bottom. so i added
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ellidokuz.com"
android:versionCode="1"
android:versionName="1.0" >
<supports-screens
android:resizeable="true"
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:anyDensity="true"
android:xlargeScreens="true"
/>
this code to manifest. then copied list_v.xml
to drawable-xhdi
and drawable-xxhdi
.
and then I changed
android:layout_width="fill_parent"
android:layout_height="174dp"
to
android:layout_width="fill_parent"
android:layout_height="350dp"
but still my application running the xml file in the layout folder. How can I set it to run xml file in drawable-xxhdpi
folder?
回答1:
You don't have to put your XML
layout file into drawable
folders!!
Instead just just put it in:
layout-small
layout-large
layout-xlarge
...
回答2:
just simple copy and paste your xml into different Layout folders
回答3:
There is some convention to achieve this as per google developers blog recommended. If you want to achieve your layout should work for both phones and tablets then there is a way to do is, create different folders for layout like layout-small, layout-mdpi, layout-hdpi, put your xml file into all the folders, but you must have same drawables folders as well with different sizes of images.
Refer this : link
回答4:
High-resolution screens exists in different screen sizes. That means you should create different layout folder like layout-sw720dp for 10-inch tablets. Then you should create a corresponding drawable folder like drawable-sw720dp-xhdpi were you can put your pictures in. I wrote a blog about this. It covers more than your question and should help getting you started. http://objectofclasshuman.blogspot.de/2014/04/android-user-interface.html
来源:https://stackoverflow.com/questions/23196569/android-multiple-screen-support-not-working