Android,为什么要使用 Button 视图,因为每个视图都可以有一个 onclicklistener
我很好奇,为什么我要使用 Button 或 ImageButton,当 TextView、ImageView 和其他所有内容都可以有 onclicklisteners,所有内容都可以有 src 和背景属性、状态以及 Button 或 ImageButton 提供的其他所有内容时,
我可能会丢失一些东西,所以请透露它是什么
I am curious, why would I ever use Button or ImageButton, when TextViews, ImageViews, and everything else all can have onclicklisteners, all can have src's and background attributes, states and everything else that a Button or ImageButton offers
I might be missing something, so please reveal what it is
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
除了默认样式之外,没有任何区别。
ImageButton
默认情况下具有非空背景。此外,
ImageButton.onSetAlpha()
方法始终返回 false,scaleType
设置为center
并且始终膨胀为可聚焦。这是
ImageButton
的默认样式:There's no differences, except default style.
ImageButton
has a non-null background by default.Also,
ImageButton.onSetAlpha()
method always returns false,scaleType
is set tocenter
and it's always inflated as focusable.Here's
ImageButton
's default style:每个人都有不同的风格,仅此而已。您可以创建一个简单的
TextView
,用户仍然可以单击它,并且您可以响应这些单击...但是TextView
默认情况下不提供任何视觉反馈。事实上,
Button
只是一个带有一组选择器可绘制对象的TextView
。Each one has different styles, that's it. You can create a simple
TextView
and users still can click on it and you can respond to those clicks... butTextView
does not offer by default any visual feedback.In fact, a
Button
is just aTextView
with a set of selector drawables.