微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

9补丁的多个阴影层?

如何解决9补丁的多个阴影层?

我正在尝试在按钮上实现this的外观。我尝试了几件事,但没有一件事奏效。我的最后一个解决方案是创建9个补丁的图像(一个图像用于左上角的光影层,另一个图像用于右下角的暗影层),并将它们组合到一个可绘制的资源文件中。像这样:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/solids">
    <nine-patch android:src="@drawable/bottom" android:dither="false" />
</item>
<item android:id="@+id/solid">
    <nine-patch android:src="@drawable/shadow1" android:dither="false" />
</item>

</layer-list>

但是它们不合适。它们看起来像this:/有人可以帮我吗?非常感谢!

编辑:另外,我还需要另外9个补丁来绘制我的cardview。在我的设计中,有一张像this这样的卡片。我从Adobe xd here获得了有关此卡的详细信息,当我按照它的确切说明进行操作时,它不合适。变得像this,我该如何解决

编辑2:This是我的Cardview的9补丁文件。这里是我的用法

<androidx.cardview.widget.CardView
                android:id="@+id/myCard"
                android:layout_width="0dp"
                android:layout_height="0dp"
                android:layout_marginTop="40dp"
                app:cardCornerRadius="20dp"
                app:layout_constraintEnd_toEndOf="@+id/card1"
                app:layout_constraintHeight_percent="0.25"
                app:layout_constraintHorizontal_bias="0.512"
                app:layout_constraintStart_toStartOf="@+id/card1"
                app:layout_constraintTop_toBottomOf="@+id/card1"
                app:layout_constraintWidth_percent="0.90">

                <androidx.constraintlayout.widget.ConstraintLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:background="@drawable/myNinePatch"/>

</androidx.cardview.widget.CardView>

注意:我不是母语人士,所以我尽力解释了一切。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。