[英]How to change AppCompatButton corner radius?
<android.support.v7.widget.AppCompatButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/logout" />
Above is my button xml it have a small corner radius by default now i need to change the radius a little bit how i can change only corner radius? 上面是我的按钮xml,默认情况下它具有较小的拐角半径,现在我需要稍微更改半径,我如何才能仅更改拐角半径?
Use custom style: create the following file into your drawable folder. 使用自定义样式:在您的可绘制文件夹中创建以下文件。
button_style.xml button_style.xml
<?xml version="1.0" encoding="UTF-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" >
<shape>
<solid
android:color="#9CD0E3" />
<stroke
android:width="7dp"
android:color="#55BDE4" />
<corners
android:radius="3dp" />
<padding
android:left="10dp"
android:top="10dp"
android:right="10dp"
android:bottom="10dp" />
</shape>
</item>
<item>
<shape>
<gradient
android:startColor="#55BDE4"
android:endColor="#55BDE4"
android:angle="270" />
<stroke
android:width="7dp"
android:color="#9DD0E2" />
<corners
android:radius="3dp" />
<padding
android:left="10dp"
android:top="10dp"
android:right="10dp"
android:bottom="10dp" />
</shape>
</item>
</selector>
example 2 (button_style.xml): only corner radius. 示例2(button_style.xml):仅拐角半径。
<?xml version="1.0" encoding="UTF-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" >
<shape>
<corners
android:radius="15dp" />
<padding
android:left="10dp"
android:top="10dp"
android:right="10dp"
android:bottom="10dp" />
</shape>
</item>
<item>
<shape>
<corners
android:radius="15dp" />
<padding
android:left="10dp"
android:top="10dp"
android:right="10dp"
android:bottom="10dp" />
</shape>
</item>
</selector>
And then use this 然后用这个
<android.support.v7.widget.AppCompatButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/searchBox"
android:background="@drawable/button_style"
android:text="@string/logout" />
Look at the android:radius="3dp"
in button_style.xml.... increase the dp as much as you want.. 查看android:radius="3dp"
中的android:radius="3dp"
。...尽可能增加dp。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.