I got this strange problem with a 9-patch in Android, which i want to use as a splash-screen. I use a build-in Android Studio plugin to create a 9-patch, but it doesnt't work properly with images with too high resolution.
This is a simplified version of what I do in generator (X is the symbol of black pixels):
X X
************X
X ************X
************X
****LOGO****X
************X
X ************X
************
XXXXXXXXXX
When i try to use it as a activity background it behaves like a normal bitmap, not like a 9-patch - it is displayed in original resolution and doesn't fit the screen. This is the code of XML file:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:drawable="@color/colorPrimary"/>
<item>
<nine-patch xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/patch_logo"
android:tileMode="disabled"
android:gravity="center"/>
</item>
</layer-list>
I decided to test it as a background of a layout, in that case it was the FrameLayout where I load fragments with initial settings. This image shows two previews - on the left is used a normal png, 800x800. On the right side is a 9-patch file of the same image.
As you can see, left image is just stretched to fit the layout. Right image, although in preview it looks like when i was using xml drawable as a background of activity, on a real device it is displayed exactly like using normal png - it is just stretched.
When I use 500x500 image 9-patch it is a little bit too big on preview, but on my device it looks good, just the resolution is too low.
All 9-patch files are stored in drawable folder, it is not specified for any density.
This is the logo I want to use logo
I was trying to find the solution all day. What am I doing wrong?