ImageButton和Button区别
一、基础准备
Imagebutton 继承 Imageview,就是用一个图标代表了一些文字,它没Android:text属性。它由Android:src指定图标的位置
android:src="@drawable/back"
Button 继承 Textview,所以TextView的一些属性也适用于Button控件。
Button把图片当作背景与放在ImageButton/ImageView中的效果是不一样的。
二、代码
1、 如何设置按钮的样式?
<Button android:id="@+id/myBtn1" android:text="按钮1 设置背景样式"android:layout_width="fill_parent" android:layout_height="wrap_content"android:background="#fff000" />
2、如何设置背景图标
<Button android:id="@+id/myBtn6" android:text="按钮6 设置背景图标"android:layout_width="wrap_content" android:layout_height="wrap_content"android:textStyle="bold" android:background="@drawable/back_48"/>
3.如何设置按钮的文字颜色
<Button android:id="@+id/myBtn2" android:text="按钮2 字体颜色"android:layout_width="fill_parent" android:layout_height="wrap_content"android:textColor="#ff0000" />
4、 如何设置按钮的文字样式
<Button android:id="@+id/myBtn3" android:text="按钮3字体加粗"android:layout_width="fill_parent" android:layout_height="wrap_content"android:textColor="#ff0000" android:textStyle="bold" />
5、 如何为按钮添加监听器注册事件
myBtn4.setOnClickListener(new OnClickListener() {@Overridepublic void onClick(View v) {myBtn4.setText("setOnclickListener事件监听注册成功");}});
1、 怎么样设置ImageButton的图标位置
Android : src
2、 怎么样为ImageButton添加监听器注册事件
实现Onclick
或者android:onClick="ImageButtonXml"
1、 设置透明度
imgBtn01.setAlpha(50);//设置透明度
ImageButton和Button区别的更多相关文章
- 一、submit和button区别
一.submit和button区别 一.HTTP方法:GET.POST
- Android ImageView,ImageButton 与 Button
1. ImageButton 继承自 ImageView.两者具备甚小,因为 ImageView 同样可以点击相应,同样有点击的阴影效果.实际上他们的区别在于默认 style.比如同样放一个背景和一个 ...
- ASP.NET控件<ASP:Button /> html控件<input type="button">区别联系
ASP.NET控件<ASP:Button />-------html控件<input type="button">杨中科是这么说的:asp和input是一样 ...
- ImageButton与Button
1.Button控件 Butotn控件,主要用来实现一些命令操作,通过注册监听事件来实现.首先需要在xml文档中放入一个button按钮. <Button android:id="@+ ...
- submit与button区别提交区别
提交表单时使用submit会自动提交form表单数据, 如果使用jquery的form表单插件时需要将提交按钮改为button时$("#表单id").ajaxSubmit({}); ...
- from中buttone 和 input type="button" 区别
在做一个表单提交时碰到的问题, 1.js判断阻止表单提交,如果是form 里面的button的话,恭喜你,你要再换个写法了.<button type="submit" ... ...
- 【读书笔记《Android游戏编程之从零开始》】3.Android 游戏开发常用的系统控件(Button、Layout、ImageButton)
3.1 Button Button这控件不用多说,就是一个按钮,主要是点击后进行相应事件的响应. 给组件添加ID属性:定义格式为 android:id="@+id/name",这里 ...
- android:ImageView 和ImageButton的区别
1.继承不同: java.lang.Object ↳ android.view.View ↳android.widget.ImageView ↳ android.widget.ImageButton ...
- 2.3.3 Button(按钮)与ImageButton(图像按钮)
本节引言: 今天给大家介绍的Android基本控件中的两个按钮控件, Button普通按钮 ImageButton图像按钮: 其实ImageButton和Button的用法基本类似,至于与图片相关的则 ...
随机推荐
- android应用版本更新功能---完整版
源码下载地址:csdn下载地址:http://download.csdn.net/download/csdn576038874/9526085 博客园下载地址:http://files.cnblogs ...
- 使用nexus创建maven私有仓库
nexus安装 nexus下载 wget https://sonatype-download.global.ssl.fastly.net/nexus/oss/nexus-2.11.1-01-bundl ...
- js验证
验证短日期(2007-06-05) function strDateTime(str) { var r = str.match(/^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1 ...
- ThinkPHP函数详解:cookie方法
cookie函数也是一个多元化操作函数,完成cookie的设置.获取和删除操作. Cookie 用于Cookie 设置.获取.删除操作 用法cookie($name, $value='', $opti ...
- 移动端布局Demo展示图文
上两张图自勉一下(来自刘墉先生的文章,最近看他的作品):然后移动端该愈来愈受到重视,未来的市场我不知道,不过我知道手机的功能越来越强大是不争的事实!移动端布局的积累也需要从现在做起! 需求一:实现下图 ...
- c语言学习之基础知识点介绍(二十):预处理指令
一.预处理指令的介绍 预处理命令:在编译之前触发的一系列操作(命令)就叫预处理命令. 特点:以#开头,不要加分号. #include: 文件包含指令 把指定文件的内容复制到相应的位置 #define: ...
- Sql2008的行列转换之行转列
今天在工作的时候遇到了行列转换的问题,记得去年有一段时间经常写,但是许久不用已经记不太得了.好记性不如烂笔头,忙完之后赶紧记录一下. 关键字:PIVOT(行转列),UNPIVOT(列转行) 先说说 P ...
- sql 常用操作脚本代码
,--运行fy_mh库[use] use fy_mh ,--查询 mh_dblj表 select * from mh_dblj ,--更新 某个字段(把表的某个字段下的所有的数据清空)[update ...
- OC - 2.OC基础知识介绍
一.基础语法 1> OC语言和C语言 C语言是面向过程的语言,OC语言是面向对象的语言 OC语言继承了C语言,并增加了面向对象的思想 以下内容只介绍OC语言与C语言的不同之处 2> 关键字 ...
- hibernate_validator_01
1.环境准备(Maven工程) <?xml version="1.0" encoding="UTF-8"?> <project xmlns=& ...