问题
im working on Supporting different Screen for android i created different drawable folders and pasted pics according to their requirments like as bellow
drawable-ldpi = 240*320 px (dimension)
drawable-mdpi = 320*480px
drawable-hdpi = 480 * 800px
drawable-xhdpi=720*1280px
and then i copy paste layouts in coresponding layout folders like
layout-small
layout-normal
layout -land
layout-land-small
etc etc now when i open the activity_main(layout) of each folder,it has to select the background photo form corresponding folders of drawable,but it select only one photo from drawable-hdpi in all layouts. where is problem???
回答1:
Android OS automatically selects drawable from specific folder. You as a developer must only provide different drawable for each folder:
drawable-xhdpi/
awesomeimage.png
drawable-hdpi/
awesomeimage.png
drawable-mdpi/
awesomeimage.png
drawable-ldpi/
awesomeimage.png
The best way to show that it works is to launch your application on real device. You can also use different devices in Android Studio in designer and pictures from different drawable folders should be applied:
Hope it helped.
回答2:
-ldpi, -mdpi, -hdpi, -xhdpi relative to resolution and -small, -normal relative to size, -land relative to oriention of device. You can change to:
layout-ldpi,
layout-mdpi,
layout-hdpi,
layout-xhdpi
to them select (Order)
drawable-ldpi = 240*320 px (dimension)
drawable-mdpi = 320*480px
drawable-hdpi = 480 * 800px
drawable-xhdpi=720*1280px
回答3:
It selects layout based on the device. It selects only one layout per device. For example, a phone with 4.5 in screen , it selects normal layout, and for tablets it selects large layout.
These folders are for different devices with different screen sizes and resolution.
As you want all the images to display. You just cant because you device is static in screen size and resolution.
Save all the images in each folders you'll get all the images. This too gets displayed from one folder.
You gotta read developer site to understand better
来源:https://stackoverflow.com/questions/33864551/supporting-different-screens