ImageButton has a non-null background by default.
ImageButton.onSetAlpha() method always returns false,
scaleType is set to
center and it’s always inflated as focusable.
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>
The image on the surface of the button is defined either by the
android:srcattribute in the
XML element or by the
|android:padding||setPaddingRelative(int,int,int,int)||Sets the padding, in pixels, of all four edges.|
|android:maxHeight||setMaxHeight(int)||An optional argument to supply a maximum height for this view.|
|android:maxWidth||setMaxWidth(int)||An optional argument to supply a maximum width for this view.|
|Lower resolution screen||Higher resolution, same size|
|Physical Width||1.5 inches||1.5 inches|
|Dots Per Inch (“dpi”)||160||240|
|Density (factor of baseline 160)||1.0||1.5|
|Density-independent Pixels (“dip” or “dp” or “dps”)||240||240|
|Scale-independent pixels (“sip” or “sp”)||Depends on user font size settings||same|
Notes: Density does not exactly follow the real screen size, pixels are not necessarily squares, there is no strict definition for what a “pixel” means. This may be confusing but not as much as CSS Units (em, ex, pt, etcetera).
The density-independent pixel is equivalent to one physical pixel on a 160 dpi screen, the baseline density assumed by the platform (as described later in this document). At run time, the platform transparently handles any scaling of the dp units needed, based on the actual density of the screen in use. The conversion of dp units to screen pixels is simple: pixels = dps * (density / 160). For example, on 240 dpi screen, 1 dp would equal 1.5 physical pixels. Using dp units to define your application’s UI is highly recommended, as a way of ensuring proper display of your UI on different screens.
set your required image in the imageview and use an onclicklistener to detect clicks like you would do for an ImageButton.
specify the width of your ImageButton and set the padding as required (this is if you want to use android:background=”#00000000″).