java android中带圆角的按钮

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/36536598/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-03 01:34:28  来源:igfitidea点击:

Buttons with rounded corners in android

javaandroidxml

提问by George

I would like to create buttons like the Sign Upand Loginbutton Heart link mockupI found the image on https://www.google.com/search?q=medicine&source=lnms&tbm=isch&sa=X&ved=0ahUKEwiuyrO8koLMAhWlJ5oKHcRuDjgQ_AUICCgC&biw=1366&bih=697#tbs=isz:lt%2Cislt:svga&tbm=isch&q=stethoscope+%2B+laptop&imgrc=Uh8IGO8X6CBcMM%3AThe methods that I have tried include using the following

我想创建像注册登录按钮这样的按钮心脏链接样机我在https://www.google.com/search?q=medicine&source=lnms&tbm=isch&sa=X&ved=0ahUKEwiuyrO8koLMAhWlJ5oKHcRuDjgQ_AUICCgC&biw=1367&bih=69s lt%2Cislt:svga&tbm=isch&q=stethoscope+%2B+laptop&imgrc=Uh8IGO8X6CBcMM%3A我尝试过的方法包括使用以下方法

  1. Using a Shape drawable

  1. 使用Shape drawable

The result so far has not been pleasant to look at.

迄今为止的结果并不令人愉快。

回答by Shadab Ansari

Try this -

试试这个 -

<shape android:shape="rectangle">
            <corners android:radius="30dp"/>
            <solid android:color="@android:color/black"/>
 </shape>

回答by George

To speed up the process I actually came across this tool that generate code for your xml http://angrytools.com/android/button/After you have modified the button to your liking all the user just has to do is copy the xml generated code into their application. The tool has a lot of customisation options which include Size, Padding, Corners, Background, Padding and Stroke.

为了加快这个过程,我实际上遇到了这个为你的 xml http://angrytools.com/android/button/生成代码的工具根据你的喜好修改按钮后,用户只需复制生成的 xml代码到他们的应用程序中。该工具有很多自定义选项,包括大小、填充、角落、背景、填充和描边。

回答by android_jain

see this you will get exactly .

看到这个你会得到准确的。

   <shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/green"/>
   />
<gradient android:angle="-90" android:startColor="@color/green" 
   android:endColor="#58857e"></gradient>
  </shape>