android中ImageView、ImageButton、Button之间的区别


1.继承不同

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

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

因而ImageButton 不支持setText,而Button支持。反之,ImageButton 支持setImageURI,而Button不支持。Button和ImageButton有Button的状态,但是ImageView没有。


2.显示差异:

imageView 加上可点击的属性同样实现button的点击功能,这样看来没啥区别,

可是可是,最近我做的listView,一个imagebutton,一个imageView 显示圆角图片的时候,imageBotton 居然显示不出来.

ImageButton 拥有默认背景:

  1. <style name="Widget.ImageButton">  
  2.      <item name="android:focusable">true</item>  
  3.      <item name="android:clickable">true</item>  
  4.      <item name="android:scaleType">center</item>  
  5.      <item name="android:background">@android:drawable/btn_default</item>  
  6.  </style>  

</pre><pre class="default prettyprint prettyprinted" name="code" style="white-space: pre-wrap; word-wrap: break-word; margin-top: 0px; margin-bottom: 10px; padding: 5px; border: 0px; vertical-align: baseline; background-color: rgb(238, 238, 238); font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; overflow: auto; width: auto; max-height: 600px; line-height: 18px;">


3.支持图片:

别人说 :ImageButton支持9.png 吧~imangeView就不行了。

其实你两者都设置了onclicklistener之后是没什么区别的……


Android学习笔记十:基本视图组件:ImageView和ImageButton

http://sarin.iteye.com/blog/1673997

你可能感兴趣的:(android中ImageView、ImageButton、Button之间的区别)