Difference between Button with image, ImageButton, and clickable ImageView?

后端 未结 5 1738
一向
一向 2021-02-01 12:14

Is there any difference between Button with image, ImageButton and clickable ImageView?

5条回答
  •  夕颜
    夕颜 (楼主)
    2021-02-01 12:41

    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.

    java.lang.Object
    ↳ android.view.View
       ↳ android.widget.ImageView
           ↳ android.widget.ImageButton
    

    versus

    java.lang.Object
    ↳ android.view.View
       ↳ android.widget.TextView
           ↳ android.widget.Button
    

提交回复
热议问题