-2

I was asking how to convert images from .9.png to .png extensions.

I've tried to rename them using ren xxx.9.png xxx.png but not work

I tried many solutions on the internet but failed.

the images are too many and hard to do manually. also, I read that doing it manually will not recognize by android studio it'll continue to see that it is .9.png too.

so can anyone help me to solve that image?

Abner Escócio
  • 2,697
  • 2
  • 17
  • 36
Moustafa EL-Saghier
  • 1,721
  • 1
  • 13
  • 43

1 Answers1

1

A .9.png or a 9-patch image is simply a .png image with a 1px border around its edges. You can read more about it here. You can see this for yourself if you click on any png resource in android and scroll through the options that popup and click on create a 9-patch file, the dialog will show a filetype of png and not 9.png although this will be reflected in the name. This link is also worth a read.

shiredude95
  • 560
  • 3
  • 7
  • I don't need to it manually as the app has too many images do you know anyway? – Moustafa EL-Saghier Jun 07 '18 at 18:17
  • Like I said, having a 9patch image is the same as having a png image(just a more adaptive version), if your app doesnt use said resources you can go ahead and delete them, but if your app does use them then its not a bad idea to have a 9patch version. – shiredude95 Jun 07 '18 at 18:59
  • won't they affect the use of aapt2 and getting some error `Error:java.util.NoSuchElementExceptionv` error? I just updated gradle version and get these error – Moustafa EL-Saghier Jun 07 '18 at 19:05
  • Did you delete some code or resources before compiling? Was it showing this error before. Try disabling instant run if you have already enabled it. Based on your Android Studio version you might need to make a few more changes as mentioned in this other post on SO https://stackoverflow.com/questions/49523739/android-studio-i-am-getting-the-following-error-java-util-nosuchelementexcepti – shiredude95 Jun 07 '18 at 20:08
  • I didn't do anything I just updated the gradle version – Moustafa EL-Saghier Jun 07 '18 at 20:24
  • I see. This most likely is a issue regarding the gradle update. You might want to look at this post: https://stackoverflow.com/questions/49523739/android-studio-i-am-getting-the-following-error-java-util-nosuchelementexcepti – shiredude95 Jun 07 '18 at 20:33
  • actual it does not solve my issue/question but you told me info that both .9.png are same .png and won't affect the project thanks for that – Moustafa EL-Saghier Jun 07 '18 at 20:52
  • To be clear, they are only slightly different in that a 9patch has a 1px border added around its edges so it can be scaled easily. Though this might create some minor size differences it has the advantage of the image being easily scalable according to the screen resolution. – shiredude95 Jun 07 '18 at 20:54
  • would that affect the resolution if image when it scale? – Moustafa EL-Saghier Jun 07 '18 at 20:56
  • A 9patch image will auto scale according to the resolution, hence the reason it being more dynamic than say a standard png. This link http://wiresareobsolete.com/2010/06/9-patches/ talks about it in detail. – shiredude95 Jun 07 '18 at 21:10
  • ok, thank you, bro, for the last question. if I created an image with the largest size and make it 9-pinch that means no more of other sizes right? – Moustafa EL-Saghier Jun 08 '18 at 14:54
  • It is *9patch, also I think you are misunderstanding the concept of 9patch. The borders are supposed to stretch out not scale down. A small image may scale well in many devices in high dp screens it might not produce expected output.So it is advised to create 9patches for all the densities. This link explains it:https://stackoverflow.com/questions/10574363/android-splash-screen-image-sizes-to-fit-all-devices – shiredude95 Jun 08 '18 at 16:09