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 ever开发者_StackOverflow社区ything else that a Button or ImageButton offers
I might be missing something, so please reveal what it is
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 to center
and it's always inflated as focusable.
Here's ImageButton
's default style:
<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>
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... but TextView
does not offer by default any visual feedback.
In fact, a Button
is just a TextView
with a set of selector drawables.
精彩评论