简体   繁体   中英

Unable to create 9patch images

I created a tab bar with images. But in my emulator images are looking good. But while running apk in mobile the tab bar images looking very small in size. So I created 9patch images from this http://romannurik.github.io/AndroidAssetStudio/nine-patches.html , I can place xyz.9.png image in my drawable folder but I can use setImageResource like img_home.setImageResource(R.drawable.footer_icon1); But if i use xyz.9.png for image resource it displays me an error. Can I keep that 9.png like as same now? How can I fix my problem. Please help me

如果9patch图像名称是xyz.9.png用于在ImageViewImageButton设置图像资源,则您只需要提供image name .9.png部分除外,如下所示

img_home.setImageResource(R.drawable.xyz);

I don't think so 9 patch images will be a right choice here. You need to cut the tab bar icons for each DPI (mdpi, hdpi, xhdpi, xxhdpi and so on) because emulator's resolution and DPI might be different than the device you are testing your app on. Take a look at Android's official guideline for icons - Android iconography

Its important to have icons for each DPI as it makes your app graphics look good and sharp throughout all the devices.

Hope it helps.

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