Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android item size in layer-list

I need to set size for item in layer-list. For using as windowBackground in launch activity. I wrote this XML file and Android Studio displays it correctly. But in application the logo always full screen. How to make it?

<?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:height="100dp"
    android:width="77dp"
    android:gravity="center"
    >

</item>
</layer-list>
like image 252
Tolyas Avatar asked Jan 29 '16 11:01

Tolyas


1 Answers

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.

like image 99
Tolyas Avatar answered Sep 24 '22 06:09

Tolyas