图层列表中的Android项目大小 [英] Android item size in layer-list

查看:72
本文介绍了图层列表中的Android项目大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要设置图层列表中项目的大小.用于在启动活动中用作windowBackground.我写了这个XML文件,Android Studio正确显示了它.但在应用中,徽标始终全屏显示.怎么做?

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>

推荐答案

我找到了解决方案,但我希望有更好的方法. 这是最终代码:

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>

至少它可以在xxhdpi和xhdpi上正常工作.

At least it works at xxhdpi and xhdpi without distortion.

这篇关于图层列表中的Android项目大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆