带有半圆形边缘的android按钮 [英] android button with half circle edges

查看:477
本文介绍了带有半圆形边缘的android按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个形状以用于我的Android项目中的图像按钮,该形状的左侧和右侧实际上将有半个圆.

I am trying to create a shape to be used for my imagebuttons in my Android project that would essentially have half circles for the left and right sides.

我以为我可以使用带有半径的XML形状,但这只是圆角,我需要整个左侧和右侧为半圆,如下图所示.

I thought I could just use a shape XML with a radius, but that just rounds the corners where I need the whole left and right sides to be half circles like the image below.

我当前的形状XML如下:

My current XML for the shape looks like this:

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

    <corners
       android:radius="60dip"
         />

    <stroke
        android:width="0dp"
        android:color="#000000" />


     <solid
        android:color="@color/white" />

</shape>

但是我正在尝试获得这种效果:

but I am trying to get this effect :

推荐答案

您的按钮有多高?具有圆角的可绘制形状应该可以工作,您希望半径为按钮高度的一半.

How tall is your button? The shape drawable with rounded corners should work, you want the radius to be half of the height of the button.

这篇关于带有半圆形边缘的android按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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