I am busy creating a less complicated version of NinePatchDrawable
that tiles the inner panels instead of stretching them.
I can implement the actual logic to do the rendering and such.
However, I can't find documentation about how to use this Drawable
in the XML files. Is this possible? That is, can I have a <tileable-nine-patch>
, or some such, tag I can use to define resources?
in Drawable folder of res in project directory, make xml file and name it as layerlist. xml and paste it below code as your requirement. you can also add your shape drawable instead of drawable in the <item/> tag in the example. and use this xml as a background of ImageView .
A drawable resource is a general concept for a graphic that can be drawn to the screen and which you can retrieve with APIs such as getDrawable(int) or apply to another XML resource with attributes such as android:drawable and android:icon . There are several different types of drawables: Bitmap File.
Step 1: In this method first of all in your system find your required images and copy the image as we do normally. Step 2: Then open the Android Studio go to the app > res > drawable > right-click > Paste as shown in the below figure. Step 3: Then a pop-up screen will arise like below.
Unfortunately it is not possible to use custom drawables in XML files (for API 23 and below) due to potential security issues. See here for a Google Groups thread about this very topic with a response from Romain Guy, one of the Android developers.
You can still use them in your Java code though.
Update:
As LeoFarage points out in the comments, starting in API 24 you can now use custom drawables in XML files but only within your application package.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With