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的用法基本类似,至于与图片相关的则 ...
随机推荐
- jedis访问redis学习笔记
最近在学习redis,在网上查了些文章,利用他人已有的知识,总结写下了这篇文章,大部分内容还是引用别人的文章内容.经过测试发现spring-data-redis现在有的版本只能支持reids 2.6和 ...
- HDU-1018(简单数学)
Big Number Problem Description In many applications very large integers numbers are required. Some o ...
- 如何创建windows xp 虚拟机
如何创建windows xp 虚拟机 一.所需软件 1. VMware-workstation-full-12.0.0-2985596 赠送vm12 激活key一枚: 5A02H-AU243 ...
- android线程池ThreadPoolExecutor的理解
android线程池ThreadPoolExecutor的理解 线程池 我自己理解看来.线程池顾名思义就是一个容器的意思,容纳的就是ThreadorRunable, 注意:每一个线程都是需要CPU分配 ...
- gdal中文路径无法打开问题
在C#中使用OGR读写矢量数据时,需要引用“using OSGeo.OGR;”. 同时为了处理中文路径和中文字段,需要在开始设置下面两个属性,代码如下: //为了支持中文路径,请添加下面这句代码(大多 ...
- Struts2 多文件下载
Step1:导入支持jar包 commons-fileupload-1.3.1.jar commons-io-2.4.jar jstl-1.2.jar standard-1.1.2.jar commo ...
- javascript闭包的理解
闭包是Javascript的一个难点,但也是一个很重要的知识点. 1.首先我们要知道变量作用域链 变量的作用域分两种:全局变量和局部变量.没有定义到任何函数中的变量为全局变量,在函数中定义的变量为局部 ...
- Spring Mvc 笔记二之异常和文件上传
spring mvc的异常与文件上传 1.异常: spring注解版的异常有局部异常和全局异常 1.局部异常对单个controller有效;(在controller类写一 ...
- 03_天气查询_socket方式模拟_多线程方式
[简述] 要重视Socket开发,企业后台服务特长使用Socket. 1.服务端要有可持续运行能力,保证线程一致在运行 2.并发处理能力,使用多线程 [工程截图] [WeatherRunner.jav ...
- GitHub Windows客户端部署
下载网址:https://windows.github.com 点击下载按钮即可下载一个小程序,这个小程序会去服务器端下载完整的Windows版客户端,然后自动安装. 如果安装出错的话,那就打开IE浏 ...