Android:创建异形按钮 [英] Android: Creating shaped button

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

问题描述

如何创建这样的自定义按钮?

How can I create a custom button like this?

它应该只是可点击区域而不是真正的按钮.

It should be just clickable area not a real button.

推荐答案

将其另存为 png 并将其放入 drawables 文件夹中.然后在你的 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.

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

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