简体   繁体   English

设置带有背景图像和圆角的按钮

[英]Setting a Button with background Image and Round corners

I know there are already questions like this but i cannot find the answer for my uestion. 我知道已经有这样的问题,但是我找不到答案。 Please Help? 请帮忙?

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/button"
      android:state_pressed="true" />
<item android:drawable="@drawable/button"
      android:state_focused="true" />
<item android:drawable="@drawable/button" />
</selector>

i already set the background but i dont know how to make the edges round. 我已经设置了背景,但是我不知道如何使边缘变圆。

Create your own custom button like this 像这样创建自己的自定义按钮

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <corners android:radius="3dp" />
    <stroke android:width="5px" android:color="#1a1a1a" />
</shape>

Also check this on Developers Site 同时在开发者网站上检查

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM