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的用法基本类似,至于与图片相关的则 ...
随机推荐
- react 组件开发
参考资料 https://toddmotto.com/react-create-class-versus-component/ React-Native的代码规范,React其实也基本一样~~ htt ...
- hibernate缓存技术
1.缓存 2.Hibernate 缓存作用:为了提高查询效率. 3.第一次操作某个对象的时候,把操作的对象数据存储到缓存中,然后下一次在对同一个对象操作的时候,就不会在连接数据库. 4.Hiberna ...
- Es6 之箭头函数 初学
不积跬步,无以至千里;不积小流,无以成江海! // ES5 var selected = allJobs.filter(function (job) { return job.isSelected() ...
- 移动端布局Demo展示图文
上两张图自勉一下(来自刘墉先生的文章,最近看他的作品):然后移动端该愈来愈受到重视,未来的市场我不知道,不过我知道手机的功能越来越强大是不争的事实!移动端布局的积累也需要从现在做起! 需求一:实现下图 ...
- C#读取Excel文档
上面分别是Excel文档的内容和读取结果: 奉上C#源代码: using System; using System.Data; using System.Data.OleDb; namespace R ...
- C#做的一个加密/解密的类
转自:http://www.16aspx.com/Article/3904 using System; using System.Security.Cryptography; using System ...
- 数组做为参数传入Oracle存储过程操作数据库
p { margin-bottom: 0.25cm; direction: ltr; color: rgb(0, 0, 0); line-height: 120%; text-align: justi ...
- iOS-scrollview及其子类适配iOS7
问题描述: 在iOS7之后如果在导航控制器中所属的字控制器中嵌入scrollview及其子类的视图,当scrollview的尺寸太小的话不会调用返回cell的方法.控制器的嵌套层级结构如下图所示,着重 ...
- 滑动条 Trackbar[OpenCV 笔记9]
OpenCV中没有实现按钮的功能,我们可以利用滑动条来实现按钮功能. , ); trackbarname 轨迹条的名字. winname 窗口的名字,轨迹条会依附在这个窗口上. value 一个指向整 ...
- [翻译][MVC 5 + EF 6] 2:基础的增删改查(CRUD)
原文:Implementing Basic CRUD Functionality with the Entity Framework in ASP.NET MVC Application 1.修改Vi ...