Android Item Size In Layer-list


Answer :

I found solution, but I expected better way. Here is final code:

<?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item>     <shape xmlns:android="http://schemas.android.com/apk/res/android"         android:shape="rectangle" >          <gradient             android:endColor="#000004"             android:gradientRadius="1000"             android:startColor="#1f3371"             android:type="radial" >         </gradient>     </shape> </item> <item>     <bitmap xmlns:android="http://schemas.android.com/apk/res/android"         android:src="@drawable/texture_5"         android:tileMode="repeat" /> </item> <item android:drawable="@drawable/logo"     android:bottom="214dp"     android:top="214dp"     android:left="100dp"     android:right="100dp"     android:gravity="center"     android:tileMode="repeat"     > </item> </layer-list> 

At least it works at xxhdpi and xhdpi without distortion.


Starting from API 23, it is possible to set width and height right within the "item" tag:

<item android:drawable="@drawable/logo" android:width="..." android:height="..." /> 

Comments

Popular posts from this blog

Converting A String To Int In Groovy

"Cannot Create Cache Directory /home//.composer/cache/repo/https---packagist.org/, Or Directory Is Not Writable. Proceeding Without Cache"

Android How Can I Convert A String To A Editable