【问题标题】:Top-Left Outer Corner左上角外角
【发布时间】:2019-04-03 14:42:08
【问题描述】:

我正在开发一个 Android 应用程序,但在使用可绘制对象时遇到了一些问题。 我试图达到这样的角落
https://imgur.com/DYWfsZI


我只想要红色区域,白色必须是透明的。
(当然最好是 xml)

【问题讨论】:

    标签: android drawable


    【解决方案1】:

    试试这个:

    1:在drawables中定义top_left_outer_bg.xml

    <?xml version="1.0" encoding="utf-8"?>
    <layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
    
        <item>
            <shape android:shape="rectangle" >
                <solid android:color="@android:color/holo_red_dark" />
            </shape>
        </item>
        <item>
            <shape xmlns:android="http://schemas.android.com/apk/res/android">
                <solid android:color="@android:color/white"/>
                <corners android:radius="50dp"
                    android:topRightRadius="0dp"
                    android:bottomRightRadius="0dp"
                    android:bottomLeftRadius="0dp"/>
            </shape>
        </item>
    
    </layer-list>
    

    2:添加 top_left_outer_bg.xml 作为布局的背景

    android:background="@drawable/top_left_outer_bg"
    

    【讨论】:

    • 嘿,谢谢你的帮助,但我之前已经试过了,但是白色区域必须是透明的
    • 尝试@android:color/transparent 而不是@android:color/white
    • 有一个问题,这个不起作用,因为这个项目是透明的,另一个是完全可见的(没有角落,只是一个矩形)
    猜你喜欢
    • 1970-01-01
    • 2021-08-21
    • 2017-11-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-05-10
    • 2017-01-18
    • 2013-12-22
    相关资源
    最近更新 更多