可点击的 ImageView 和 ImageButton 之间的区别 [英] Difference between a clickable ImageView and ImageButton
问题描述
我只是想知道设置为可点击的 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
?
是否有任何理由使用一个而不是另一个?ImageButton
的 drawable 是否有任何限制,使 ImageView
成为唯一可能的选择?
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?
如果我选择可点击的 ImageView
而不是 ImageButton
,我是否会失去按钮的任何功能?
Will I possibly lose any functionality of a button if I opt for a clickable ImageView
over ImageButton
?
推荐答案
除了默认样式外,没有任何区别.ImageButton
默认为非空背景.
There's no differences, except default style. ImageButton
has a non-null background by default.
EDIT:另外,ImageButton.onSetAlpha()
方法总是返回 false,scaleType
设置为 center
它总是被夸大为可聚焦.
EDIT: Also, ImageButton.onSetAlpha()
method always returns false, scaleType
is set to center
and it's always inflated as focusable.
这是ImageButton
的默认样式:
<style name="Widget.ImageButton">
<item name="android:focusable">true</item>
<item name="android:clickable">true</item>
<item name="android:scaleType">center</item>
<item name="android:background">@android:drawable/btn_default</item>
</style>
这篇关于可点击的 ImageView 和 ImageButton 之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!