Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android, why ever use Button views, since every view can have an onclicklistener

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

like image 348
CQM Avatar asked Jan 17 '26 20:01

CQM


1 Answers

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>
like image 70
Waza_Be Avatar answered Jan 21 '26 07:01

Waza_Be



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!