【发布时间】:2021-09-04 18:31:44
【问题描述】:
【问题讨论】:
标签: android xml android-layout
【问题讨论】:
标签: android xml android-layout
您可以创建两个自定义形状并将它们设置为按钮背景 (android:background="@drawable/sample")
第一个按钮的示例
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="160dp"
android:height="80dp"
android:viewportWidth="52.652084"
android:viewportHeight="21.166666">
<path
android:fillColor="#F44336"
android:pathData="M31.214,0.036 L2.229,0.027C0.332,0.026 0.104,0.811 0.101,1.862l-0.047,16.618c-0.003,1.466 -0.185,2.731 1.932,2.729L51.342,21.175c1.381,0.096 1.798,-0.748 0.581,-2.647L45.639,9.214 40.544,1.907C39.687,0.67 39.285,0.305 38.061,0.138 36.744,-0.042 34.414,0.081 31.214,0.036Z"
android:strokeWidth="1.11766827"/>
</vector>
要创建矢量,您可以使用 Inkscape、Gimp 或 Illustrator 等软件
另一种选择是在LinearLayout 中创建两个按钮,并使用Shape Theming 设置自定义样式,其中包含剪切cornerFamily 和您想要的大小。
查看this answer 以获得一个很好的例子。
【讨论】: