简体   繁体   中英

How can I make images fit every device on android application

I am inserting buttons and images which should touch the borders horizontally of the android device's width, but they are not a result there is little space left on both the sides of the button and images. And when I test the app on a larger dimension device the images and button appear pretty small comparatively. What should I do?

These links will help you to create application for multiple screens :

http://developer.android.com/training/multiscreen/screensizes.html

http://developer.android.com/guide/practices/screens_support.html

These are android's official documents on implementing support for multiple screen sizes.

<supports-screens android:smallScreens="true" 
          android:normalScreens="true" 
          android:largeScreens="true"
          android:xlargeScreens="true"
          android:anyDensity="true" />

Add this to your manifest file of your application.

there is little space left on both the sides of the button and images

Try changing the margin and padding of your UI components.

And when I test the app on a larger dimension device the images and button appear pretty small comparatively.

Android documentation provides pretty detailed information on what size image should be used for various screen sizes. You might want to read that.

In your XML file you can use android:scaleType . See documentation for scaleType .

scaleType is a bit difficult to understand with the provided description unless you use each scale type and see its effects for yourself.

Programmatically you can do something like this but it would very much depend on your particular use case requirement.

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