一个可点击的ImageView和ImageButton的区别 [英] Difference between a clickable ImageView and ImageButton
问题描述
我只是想知道如果有之间的的ImageView
就是设置为可点击的,有比较的ImageButton $ C任何显著差异$ C>?
I'm just wondering if there is any significant difference between an ImageView
that's set to be clickable, compared with an ImageButton
?
是否有任何理由使用一个比其他?是否有被拉伸为任何限制的ImageButton
的叶的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.
修改:另外, ImageButton.onSetAlpha()
方法始终返回false, scaleType
设置为中心
键,它总是夸大的可获得焦点。
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屋!