一、基础准备

      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() { 
                     @Override 
 
                     public void onClick(View v) { 
 
                            myBtn4.setText("setOnclickListener事件监听注册成功"); 
                     } 
              }); 

           1、  怎么样设置ImageButton的图标位置

        Android :  src

            2、  怎么样为ImageButton添加监听器注册事件

          实现Onclick

         或者android:onClick="ImageButtonXml"

          1、  设置透明度

imgBtn01.setAlpha(50);//设置透明度

ImageButton和Button区别的更多相关文章

  1. 一、submit和button区别

    一.submit和button区别 一.HTTP方法:GET.POST

  2. Android ImageView,ImageButton 与 Button

    1. ImageButton 继承自 ImageView.两者具备甚小,因为 ImageView 同样可以点击相应,同样有点击的阴影效果.实际上他们的区别在于默认 style.比如同样放一个背景和一个 ...

  3. ASP.NET控件<ASP:Button /> html控件<input type="button">区别联系

    ASP.NET控件<ASP:Button />-------html控件<input type="button">杨中科是这么说的:asp和input是一样 ...

  4. ImageButton与Button

    1.Button控件 Butotn控件,主要用来实现一些命令操作,通过注册监听事件来实现.首先需要在xml文档中放入一个button按钮. <Button android:id="@+ ...

  5. submit与button区别提交区别

    提交表单时使用submit会自动提交form表单数据, 如果使用jquery的form表单插件时需要将提交按钮改为button时$("#表单id").ajaxSubmit({}); ...

  6. from中buttone 和 input type="button" 区别

    在做一个表单提交时碰到的问题, 1.js判断阻止表单提交,如果是form 里面的button的话,恭喜你,你要再换个写法了.<button type="submit" ... ...

  7. 【读书笔记《Android游戏编程之从零开始》】3.Android 游戏开发常用的系统控件(Button、Layout、ImageButton)

    3.1 Button Button这控件不用多说,就是一个按钮,主要是点击后进行相应事件的响应. 给组件添加ID属性:定义格式为 android:id="@+id/name",这里 ...

  8. android:ImageView 和ImageButton的区别

    1.继承不同: java.lang.Object ↳ android.view.View ↳android.widget.ImageView ↳ android.widget.ImageButton ...

  9. 2.3.3 Button(按钮)与ImageButton(图像按钮)

    本节引言: 今天给大家介绍的Android基本控件中的两个按钮控件, Button普通按钮 ImageButton图像按钮: 其实ImageButton和Button的用法基本类似,至于与图片相关的则 ...

随机推荐

  1. Building and setting up QT environment for BeagleBone

    There are too few information available on how to easily setup QT environment for building Beaglebon ...

  2. Container.ItemIndex 获取到行的序号

    如果在ASP.NET中应用了Repeater.Gridview,想获取到行的序号,很简单,使用Container.ItemIndex即可.在Gridview中使用<%# Container.Da ...

  3. ActionBar功能,效果图一览

    这里提供了效果预览,如果由你需要的界面,详细的代码可以去看原文. http://blog.csdn.net/android2me/article/details/8874846 一.概述 1.App ...

  4. php中实现精确设置session过期时间的方法

    http://www.jb51.net/article/52309.htm 大多数据情况下我们对于session过期时间使用的是默认设置的时间,而对于一些有特殊要求的情况下我们可以设置一下sessio ...

  5. Oracle hextoraw和rawtohex

    Oracle hextoraw和rawtohex [日期:2012-07-17] 来源:Linux社区  作者:adrain_001 [字体:大 中 小]     HEXTORAW  语法: HEXT ...

  6. linux yum配置

    yum源模版 vi /etc/yum.repos.d/xxx.repo [rhel-server]name=serverbaseurl=file:///media/disk/Serverenabled ...

  7. IOS-开发日志-UIScrollView

    UIScrollView 1.  contentOffset 默认CGPointZero,用来设置scrollView的滚动偏移量. // 设置scrollView的滚动偏移量 scrollView. ...

  8. DataTable.ImportRow()与DataTable.Rows.Add()的区别

    今天写代码的时候用到ImportRow()向DataTable中添加记录,代码如下: DataTable dt = datatable;DataRow dr = dt.NewRow();dr[&quo ...

  9. mysql 根据某个字段将多条记录的某个字段拼接成一个字段

    未合并情况 SELECT a.id, b.name AS "role" FROM sys_user a INNER JOIN sys_user_role c ON a.id=c.u ...

  10. form 表单 action 参数 接收不了

    <form method="get" action="/test/index.php?mod=123456" > <input type=&q ...