如何在Android中制作胶囊形状按钮? [英] how to make a capsule shape Button in android?

查看:476
本文介绍了如何在Android中制作胶囊形状按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要制作一个与该图片完全相同的按钮

I want to make a button exactly like in this image

我想使用一个XML文件,该文件将用于产生这样的按钮.谁能告诉我该怎么做?

I want to use a xml file that will used to produce such button. Can anyone tell me how to do that?

推荐答案

最后,我找到了使用xml文件的方法.这是给我胶囊形状按钮的xml文件代码.

finally I found the way to do it with xml file. here is the code of the xml file that gave me the capsule shape button.

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

  <corners
    android:bottomLeftRadius="30dp"
    android:bottomRightRadius="30dp"
    android:radius="60dp"
    android:topLeftRadius="30dp"
    android:topRightRadius="30dp" />

  <solid android:color="#CFCFCF" />

  <padding
    android:bottom="0dp"
    android:left="0dp"
    android:right="0dp"
    android:top="0dp" />

  <size
    android:height="60dp"
    android:width="270dp" />

</shape>    

这篇关于如何在Android中制作胶囊形状按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆