简体   繁体   中英

how to create button with an icon?

I'm creating a app which contains many button, Each button's background is different. I have created button background from Photoshop. Now my question is what should be the size of background. I have kept my button height and width as wrap content. When i use android:background:"@drawable/background_img" (image size 30X30), the buttons look like broken (like blurry). What is the best size for background which suits for all screen.

Use a ImageButton set width and height as you like and then set android:scaleType="fitCenter" and android:adjustViewBounds="true" . Try to use bigger image input than 30x30 (its to small), try 96x96 and then try to fit it to height and width you want.

A few days ago i had the same problem, when i gave 32x32 images were blurry, but when I try 64x64 or 96x96 (dont't remember) and android:scaleType="fitCenter" and android:adjustViewBounds="true" it looks so much better.

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