【问题标题】:trouble with layer-list in xml drawable?xml drawable中的图层列表有问题吗?
【发布时间】:2017-05-10 10:40:18
【问题描述】:

我正在尝试使用 xml 设计布局。这是一个聊天气泡布局。我只需要一个形状放在一个形状之后。基本上我使用 2 个矩形 1 个旋转 45 度的矩形。我需要将倾斜的矩形放在普通矩形之后。

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <rotate
            android:fromDegrees="-45"
            android:pivotX="0%"
            android:pivotY="0%"
            android:toDegrees="0" >
            <shape android:shape="rectangle" >
                <solid android:color="@color/chat_incoming_color" />
            </shape>
        </rotate>
    </item>
    <item android:left="16dp">
        <shape android:shape="rectangle" >
            <solid android:color="@color/chat_incoming_color" />
            <corners android:radius="4dp" />
        </shape>
    </item>
</layer-list>

http://imgur.com/j556772 图像显示在该图像第一部分的链接中,但第二个布局的背景应该相应地制作..

【问题讨论】:

  • “之后”到底是什么意思? “并排”?还是“低于 y 方向”?还是“低于 z 方向”?
  • 我必须先放置普通矩形,然后再放置倾斜矩形
  • 你还没有回答我的问题。 “关注”到底是什么意思?
  • 我的意思是并排
  • 在这种情况下只需使用 9-patch drawable

标签: android xml android-layout xml-drawable


【解决方案1】:

试试这个,希望它能帮助你理解你的问题。

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

        <item>
            <rotate android:fromDegrees="45"
                    android:pivotX="-35%"
                    android:pivotY="91%"
                    android:toDegrees="0">
                <shape>
                    <solid android:color="@android:color/darker_gray"/>
                </shape>
            </rotate>
        </item>
        <item android:left="16dp">
            <shape android:shape="rectangle">
                <solid android:color="@android:color/darker_gray"/>
                <corners android:radius="4dp"/>
            </shape>
        </item>

    </layer-list>

【讨论】:

  • 好的..我可以确切地知道你想要什么吗?
  • 我提供了图片的链接。在该布局中,第一部分还可以,但我无法根据需要修改第二部分。
猜你喜欢
  • 2017-07-30
  • 1970-01-01
  • 2011-06-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-09-16
  • 1970-01-01
相关资源
最近更新 更多