【问题标题】:Round arrow shape button圆形箭头形状按钮
【发布时间】:2022-02-24 01:00:07
【问题描述】:

现在我有这个按钮使用我从这个线程得到的形状主题。

Android: Make a button with triangle shape using xml definitions (drawable)

代码:

<style name="ShapeAppearanceOverlay.Button.Triangle" parent="">
        <item name="cornerFamily">rounded</item>
        <item name="cornerSizeTopLeft">4dp</item>
        <item name="cornerSizeBottomLeft">4dp</item>
        <item name="cornerFamilyTopRight">cut</item>
        <item name="cornerFamilyBottomRight">cut</item>
        <item name="cornerSizeTopRight">50%</item>
        <item name="cornerSizeBottomRight">50%</item>
</style>

但我需要在三角形的所有角上像这个按钮一样的圆角

非常感谢

【问题讨论】:

  • 向平面设计师索取此背景矢量图。
  • 我知道这不是一个选项,因为按钮的最后部分,即三角形,必须始终具有相同的宽度。应该可变的是矩形部分。

标签: android kotlin material-design shapes


【解决方案1】:

添加形状

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

<item android:width="150dp" android:height="50dp" android:right="6dp">
    <shape>
        <solid android:color="@android:color/holo_green_dark"/>
        <corners
            android:bottomLeftRadius="5dp"
            android:topLeftRadius="5dp"
            android:topRightRadius="4dp"
            android:bottomRightRadius="3dp"/>
    </shape>
</item>

<item android:width="35dp"
    android:height="35dp"
    android:left="148dp">
    <rotate android:fromDegrees="44"
        android:pivotX="0"
        android:pivotY="0">
        <shape>
            <solid android:color="@android:color/holo_green_dark"/>
            <corners
                android:topLeftRadius="2dp"
                android:bottomLeftRadius="1dp"
                android:topRightRadius="5dp"
                android:bottomRightRadius="2dp"/>
        </shape>

    </rotate>
</item></layer-list>

【讨论】:

  • 我的按钮需要匹配父宽度。您的解决方案具有 150dp 的静态宽度
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-02-21
  • 2012-08-28
  • 1970-01-01
  • 2014-04-30
  • 2016-11-14
  • 1970-01-01
相关资源
最近更新 更多