可点击的 ImageView 和 ImageButton 之间的区别
我只是想知道设置为可点击的 ImageView
与 ImageButton
相比是否有任何显着差异?
有什么理由使用其中一种而不是另一种吗?对于 ImageButton
的可绘制对象是否有任何限制,使 ImageView
成为唯一可能的选项?
如果我选择可点击的 ImageView
而不是 ImageButton
,我是否可能会失去按钮的任何功能?
I'm just wondering if there is any significant difference between an ImageView
that's set to be clickable, compared with an ImageButton
?
Is there any reason for using one over the other? Is there any restriction on the drawable for an ImageButton
that leaves ImageView
as the only possible option?
Will I possibly lose any functionality of a button if I opt for a clickable ImageView
over ImageButton
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
除了默认样式外,没有任何区别。
ImageButton
默认情况下具有非空背景。编辑:此外,
ImageButton.onSetAlpha()
方法始终返回 false,scaleType
设置为center
并且始终膨胀为可聚焦。这是
ImageButton
的默认样式:There are no differences, except default style.
ImageButton
has a non-null background by default.EDIT: Also,
ImageButton.onSetAlpha()
method always returns false,scaleType
is set tocenter
and it's always inflated as focusable.Here's
ImageButton
's default style:ImageButton 是从 ImageView 继承的,
正如 @Micheal 所描述的,我只是在他的答案中添加了详细信息
ImageButton is inherited from ImageView
as @Micheal describe i just add details to his answer
单击按钮时的效果对于 imagebutton 有,但对于 imageView 没有。
The effect of a button click when I click is there for imagebutton but not for imageView.
如果需要,您可以将按钮 CLIC 效果作为背景。 ImageButton默认有效果。
If you want, you can give the button clic effect as a background. ImageButton has an effect by default.