如何在标准Android按钮(@android:style / Widget.Button.Small)上实现圆角

问题描述 投票:0回答:1

我知道形状和内容,但问题是我想使用SDK中的标准android按钮(@android:style / Widget.Button.Small)。请看一下屏幕截图。我知道如何用“形状”然后用“纯色”(是纯色)做圆角,但是我想从库中选择.png ...

enter image description here

卡不起作用...

enter image description here

android xml kotlin rounding rounded-corners
1个回答
1
投票

如果您不想绘制任何图形,那么一种解决方法是尝试将按钮添加到cardview

请找到下面的代码

<androidx.cardview.widget.CardView
    android:layout_width="@dimen/_150sdp"
    android:layout_height="@dimen/_40sdp"
    app:cardCornerRadius="@dimen/_8sdp"
    android:layout_marginTop="@dimen/_10sdp"
    app:cardElevation="@dimen/_5sdp"
    android:layout_gravity="center">

    <androidx.appcompat.widget.AppCompatButton
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        style="@style/Widget.AppCompat.Button.Borderless"/>

</androidx.cardview.widget.CardView>

我希望这可以帮助您!

谢谢。

© www.soinside.com 2019 - 2024. All rights reserved.