Is there any difference between Button
with image, ImageButton
and clickable ImageView
?
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
The differences can be subtle. The most direct way to understanding this is to start with looking at the docs. If you look at the docs for Button you can see that
Button
is derived fromTextView
.ImageButton
on the other hand is derived fromImageView
. So fundamentally, aButton
can have text and is clickable, whereas anImageButton
is a bit more flexible in how you set the image. It has methods from itsImageView
base class likesetImageURI
which aButton
does not. One of the differences between these two and just a plainImageView
is that you can have button states which is explained in both of theButton
andImageButton
docs.ImageButton = Diaplay
Images asimageView
andget click
effect as button(android:src)
and cannot set text to it.This probably only covers part of the differences, it would be helpful to actually look at the Android Source tree to see exactly what's going on.
ImageButtons has push states, where as a clickable image does not. You also can't call setText for ImageButton, you can with a regular button.
They all derive from view, but looking at the following extends chain may help a little.
versus
One other aspect not mentioned in the previous answers is the usage within (for instance) a list item view. If you an embed a Button or ImageButton, the rest of the list item will not receive touch events. But if you use ImageView, it will.