android如何更改< item>宽度和高度 [英] android how to change <item> width and height

查看:90
本文介绍了android如何更改< item>宽度和高度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为创建一个<layer-list>.

我有我的背景图片,我希望第二层要小一些, 但是看来我在android:layer_widthandroid:layer_height中编写的内容并不重要.

I have my background image, and I want the second layer to be smaller, but it seems that doesn't matter what I'm writing inside my android:layer_width and android:layer_height.

第二层大小仍然相同.

这是我的xml:

<?xml version="1.0" encoding="utf-8"?>
<layer-list
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">

    <item
        android:drawable="@drawable/picuser" 
        android:layout_width="50dp"
        android:layout_height="50dp" />

    <item
        android:drawable="@drawable/ic_launcher" 
        android:layout_width="10dp"
        android:layout_height="10dp" />
</layer-list>

推荐答案

我希望这可以使您朝正确的方向前进:

I hope this put you on the right direction:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:drawable="@drawable/picuser"/>

    <item>

        <bitmap
            android:src="@drawable/ic_launcher"
            android:gravity="center" />
    </item>
</layer-list>

您可以在此处<item>没有layout_width/layout_height属性.

As you can see here, <item> doesn't have layout_width/layout_height attributes.

这篇关于android如何更改&lt; item&gt;宽度和高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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