I want to change the background of the layout when I click it. The layout does not always have the same shape, so I created an image with 9 patches that will support centering the image. My image looks like this:

Then my xml selector looks like this:
<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android" > <item android:state_pressed="true" android:drawable="@drawable/my_selector" /> <item> <shape android:shape="rectangle"> <solid android:color="#00ffffff" /> </shape> </item> </selector>
When I had this code and my image was not a 9 patch, it was stretched to fill. Despite the fact that I changed the image to 9-patch, it still treats the image as a regular .png file. There are even black dots in the corner and all that.

I am wondering why the 9-patch image of the image is not respected and is simply treated like a regular .png file.
source share