android中ImageView、ImageButton、Button之间的区别
来源:互联网 发布:一手数据 编辑:程序博客网 时间:2024/04/30 05:27
1.继承不同:
java.lang.Object ↳ android.view.View ↳android.widget.ImageView ↳ android.widget.ImageButtonjava.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 拥有默认背景:
<div class="dp-highlighter bg_html" style="font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px; width: 887.03125px; overflow: auto; padding-top: 1px; margin: 18px 0px !important; background-color: rgb(231, 229, 220);"><div class="bar" style="padding-left: 45px;"><div class="tools" style="padding: 3px 8px 10px 10px; font-size: 9px; line-height: normal; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; color: silver; border-left-width: 3px; border-left-style: solid; border-left-color: rgb(153, 153, 153); background-color: rgb(248, 248, 248);"><strong>[html]</strong> <a target=_blank href="http://blog.csdn.net/zapzqc/article/details/8497210#" class="ViewSource" title="view plain" style="color: rgb(160, 160, 160); text-decoration: none; border: none; padding: 0px; margin: 0px 10px 0px 0px; font-size: 9px; background-image: none; background-attachment: initial; background-color: inherit; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;">view plain</a><a target=_blank href="http://blog.csdn.net/zapzqc/article/details/8497210#" class="CopyToClipboard" title="copy" style="color: rgb(160, 160, 160); text-decoration: none; border: none; padding: 0px; margin: 0px 10px 0px 0px; font-size: 9px; background-image: none; background-attachment: initial; background-color: inherit; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;">copy</a><a target=_blank href="http://blog.csdn.net/zapzqc/article/details/8497210#" class="PrintSource" title="print" style="color: rgb(160, 160, 160); text-decoration: none; border: none; padding: 0px; margin: 0px 10px 0px 0px; font-size: 9px; background-image: none; background-attachment: initial; background-color: inherit; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;">print</a><a target=_blank href="http://blog.csdn.net/zapzqc/article/details/8497210#" class="About" title="?" style="color: rgb(160, 160, 160); text-decoration: none; border: none; padding: 0px; margin: 0px 10px 0px 0px; font-size: 9px; background-image: none; background-attachment: initial; background-color: inherit; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;">?</a><div style="position: absolute; left: 512px; top: 654px; width: 29px; height: 14px; z-index: 99;"></div></div></div><ol start="1" class="dp-xml" style="padding: 0px; border: none; list-style-position: initial; list-style-image: initial; color: rgb(92, 92, 92); margin: 0px 0px 1px 45px !important; background-color: rgb(255, 255, 255);"><li class="alt" style="border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(153, 153, 153); list-style: decimal-leading-zero outside; color: inherit; margin: 0px !important; padding: 0px 3px 0px 10px !important; background-color: rgb(245, 250, 226);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="tag" style="margin: 0px; padding: 0px; border: none; color: blue; font-weight: bold; background-color: inherit;"><</span><span class="tag-name" style="margin: 0px; padding: 0px; border: none; color: blue; font-weight: bold; background-color: inherit;">style</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;"> </span><span class="attribute" style="margin: 0px; padding: 0px; border: none; color: red; background-color: inherit;">name</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">=</span><span class="attribute-value" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"Widget.ImageButton"</span><span class="tag" style="margin: 0px; padding: 0px; border: none; color: blue; font-weight: bold; background-color: inherit;">></span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;"> </span></span></li><li style="border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(153, 153, 153); list-style: decimal-leading-zero outside; color: rgb(85, 85, 85); margin: 0px !important; padding: 0px 3px 0px 10px !important; background-color: rgb(245, 250, 226);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"> <span class="tag" style="margin: 0px; padding: 0px; border: none; color: blue; font-weight: bold; background-color: inherit;"><</span><span class="tag-name" style="margin: 0px; padding: 0px; border: none; color: blue; font-weight: bold; background-color: inherit;">item</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;"> </span><span class="attribute" style="margin: 0px; padding: 0px; border: none; color: red; background-color: inherit;">name</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">=</span><span class="attribute-value" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"android:focusable"</span><span class="tag" style="margin: 0px; padding: 0px; border: none; color: blue; font-weight: bold; background-color: inherit;">></span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">true</span><span class="tag" style="margin: 0px; padding: 0px; border: none; color: blue; font-weight: bold; background-color: inherit;"></</span><span class="tag-name" style="margin: 0px; padding: 0px; border: none; color: blue; font-weight: bold; background-color: inherit;">item</span><span class="tag" style="margin: 0px; padding: 0px; border: none; color: blue; font-weight: bold; background-color: inherit;">></span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;"> </span></span></li><li class="alt" style="border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(153, 153, 153); list-style: decimal-leading-zero outside; color: inherit; margin: 0px !important; padding: 0px 3px 0px 10px !important; background-color: rgb(245, 250, 226);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"> <span class="tag" style="margin: 0px; padding: 0px; border: none; color: blue; font-weight: bold; background-color: inherit;"><</span><span class="tag-name" style="margin: 0px; padding: 0px; border: none; color: blue; font-weight: bold; background-color: inherit;">item</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;"> </span><span class="attribute" style="margin: 0px; padding: 0px; border: none; color: red; background-color: inherit;">name</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">=</span><span class="attribute-value" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"android:clickable"</span><span class="tag" style="margin: 0px; padding: 0px; border: none; color: blue; font-weight: bold; background-color: inherit;">></span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">true</span><span class="tag" style="margin: 0px; padding: 0px; border: none; color: blue; font-weight: bold; background-color: inherit;"></</span><span class="tag-name" style="margin: 0px; padding: 0px; border: none; color: blue; font-weight: bold; background-color: inherit;">item</span><span class="tag" style="margin: 0px; padding: 0px; border: none; color: blue; font-weight: bold; background-color: inherit;">></span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;"> </span></span></li><li style="border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(153, 153, 153); list-style: decimal-leading-zero outside; color: rgb(85, 85, 85); margin: 0px !important; padding: 0px 3px 0px 10px !important; background-color: rgb(245, 250, 226);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"> <span class="tag" style="margin: 0px; padding: 0px; border: none; color: blue; font-weight: bold; background-color: inherit;"><</span><span class="tag-name" style="margin: 0px; padding: 0px; border: none; color: blue; font-weight: bold; background-color: inherit;">item</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;"> </span><span class="attribute" style="margin: 0px; padding: 0px; border: none; color: red; background-color: inherit;">name</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">=</span><span class="attribute-value" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"android:scaleType"</span><span class="tag" style="margin: 0px; padding: 0px; border: none; color: blue; font-weight: bold; background-color: inherit;">></span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">center</span><span class="tag" style="margin: 0px; padding: 0px; border: none; color: blue; font-weight: bold; background-color: inherit;"></</span><span class="tag-name" style="margin: 0px; padding: 0px; border: none; color: blue; font-weight: bold; background-color: inherit;">item</span><span class="tag" style="margin: 0px; padding: 0px; border: none; color: blue; font-weight: bold; background-color: inherit;">></span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;"> </span></span></li><li class="alt" style="border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(153, 153, 153); list-style: decimal-leading-zero outside; color: inherit; margin: 0px !important; padding: 0px 3px 0px 10px !important; background-color: rgb(245, 250, 226);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"> <span class="tag" style="margin: 0px; padding: 0px; border: none; color: blue; font-weight: bold; background-color: inherit;"><</span><span class="tag-name" style="margin: 0px; padding: 0px; border: none; color: blue; font-weight: bold; background-color: inherit;">item</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;"> </span><span class="attribute" style="margin: 0px; padding: 0px; border: none; color: red; background-color: inherit;">name</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">=</span><span class="attribute-value" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"android:background"</span><span class="tag" style="margin: 0px; padding: 0px; border: none; color: blue; font-weight: bold; background-color: inherit;">></span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">@android:drawable/btn_default</span><span class="tag" style="margin: 0px; padding: 0px; border: none; color: blue; font-weight: bold; background-color: inherit;"></</span><span class="tag-name" style="margin: 0px; padding: 0px; border: none; color: blue; font-weight: bold; background-color: inherit;">item</span><span class="tag" style="margin: 0px; padding: 0px; border: none; color: blue; font-weight: bold; background-color: inherit;">></span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;"> </span></span></li><li style="border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(153, 153, 153); list-style: decimal-leading-zero outside; color: rgb(85, 85, 85); margin: 0px !important; padding: 0px 3px 0px 10px !important; background-color: rgb(245, 250, 226);"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"> <span class="tag" style="margin: 0px; padding: 0px; border: none; color: blue; font-weight: bold; background-color: inherit;"></</span><span class="tag-name" style="margin: 0px; padding: 0px; border: none; color: blue; font-weight: bold; background-color: inherit;">style</span><span class="tag" style="margin: 0px; padding: 0px; border: none; color: blue; font-weight: bold; background-color: inherit;">></span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;"> </span></span></li></ol></div>
3.支持图片:
别人说 :ImageButton支持9.png 吧~imangeView就不行了。
0 0
- android中ImageView、ImageButton、Button之间的区别
- android中ImageView、ImageButton、Button之间的区别
- Android中Button,ImageButton,ImageView之间的区别
- android中ImageView、ImageButton、Button之间的区别
- Android中ImageView、ImageButton、Button之间的区别
- android中ImageView、ImageButton、Button之间的区别
- android中ImageView、ImageButton、Button之间的区别
- android:ImageView 和ImageButton的区别
- android Button ImageButton 区别
- android Button ImageButton 区别
- android Button ImageButton 区别
- Android ImageButton和Button的区别
- android ImageButton 和Button的图标区别
- android ImageButton和Button区别
- ImageView和ImageButton的区别
- ImageButton与ImageView的区别
- Android中ImageView和ImageButton
- FAQ_15_android Imageview ImageButton Button
- ubuntu常见错误--could not get lock /var/lib/dpkg/lock -open
- AndroidStudio创建项目时一直处于building“project name”gradle project info的解决办法
- RPG的错排
- redis 入门(一)
- JAVA 开发平台的技术和框架(五)日志管理 :common-logging slf4j log4j logBack
- android中ImageView、ImageButton、Button之间的区别
- 欢迎使用CSDN-markdown编辑器
- 平凡的世界
- tar命令的详细解释
- CSS布局小技巧
- 一台电脑运行两个tomcat,6与7
- 公开课机器学习笔记(5)逻辑回归
- 如何去除Visual Studio 中文下的红线
- flex用单例关闭窗口