简体   繁体   中英

Fit the image size (stored in assets folder) into different size of screen

I have all my images in the assets file for showing in my andorid app. In order to fit the resolution of most of the android phone, I have created most of the images at size 1280 * 800 with resolution 160 dpi. I am not sure if it's a proper way...

However, when I try to run the app, it seems that the phone could not adjust the image automatically. I would like to ask how to code the program so that the phone could adjust the image according to the phone screen size?

Thank you.

我不确定它是否会有所帮助,但更好的是使用dip(密度无关像素)而不是dpi,后者取决于屏幕密度,而前者则不然。

1280 x 800 isn't a resolution that is actually supported by any device. Honeycomb devices (which have that resolution) all allot space for the Action bar and the Status bar, so you need to account for that, if you're trying to make images that are full screen. You can set your images to preserve their aspect ratio, and then set them to fill parent vertically and wrap content horizontally (or vice versa) and you will wind up seeing them looking like they scale correctly, and leave them at 72dpi The devices will display them correctly.

<ImageView
        android:adjustViewBounds="true"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
/>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM