安卓:创建形状的按钮 [英] Android: Creating shaped button

查看:138
本文介绍了安卓:创建形状的按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何创建一个自定义按钮这样吗?

How can I create a custom button like this?

这应该只是点击区域不是一个真正的按钮。

It should be just clickable area not a real button.

推荐答案

保存为PNG和并把它放在你的可绘制文件夹。然后,在你的XML使用类似这样

save that as a png and and put it in your drawables folder. Then in your xml use something like this

<Button
android:height="wrap_content"
android:width="wrap_content"
android:background="@drawable/your_png"
/>

我不是100%肯定的是,角落里切出会正常工作。该走了那个角球区可能最终会被点击。如果是这样的话,如果你不希望它是,那么你就必须切成两半你的照片的地方创建两个按钮,可以设置旁互相弥补的形状,并使用相同的点击监听器都。从用户的角度来看,它仍然看起来像一个按钮。

I am not 100% positive that the corner cut out is going to work properly. That corner area that is gone may end up being clickable. If that is the case and if you don't want it to be then you'll have to slice your picture in half somewhere create two buttons that you can set next to each other to make up that shape and use the same click listener for both. From the users perspective it will still seem like one button.

这篇关于安卓:创建形状的按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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