<!-- 按钮设置按下去的不同效果的方式,设置android:background属性,
下面的 button_select实际上是button_select.xml --> <Button
android:id="@+id/btn_contentprovider"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/button_select"
android:text="无图的联系人" >
</Button>

button_select.xml :

 <?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android"> <!-- 本xml名:button_select.xml, 设置按钮按下去的效果,实际上就是不同的图片 -->
<item android:drawable="@drawable/btn_normal" android:state_pressed="false"></item>
<item android:drawable="@drawable/btn_pressed" android:state_pressed="true"></item> </selector>

btn_normal.png:

btn_pressed.png

android设置按钮按下的不同效果图的更多相关文章

  1. UI设计篇·入门篇·绘制简单自定义矩形图/设置按钮按下弹起颜色变化/设置图形旋转

    Android的基本控件和图形有限,难以满足所有的实际需要和设计需求,好在Android给出了相对完善的图形绘制和自定义控件的API,利用这些API,可以基本满足设计的需求. 自定义图像和控件的方法: ...

  2. Android设置按钮为透明

    设置一个按钮为透明, (1)修改配置文件 <Button android:id="@+id/btnAppMore"     android:layout_width=&quo ...

  3. Android 设置按钮为透明

    设置一个按钮为透明, (1)修改配置文件 <Button android:id="@+id/btnAppMore" android:layout_width="wr ...

  4. Android 设置按钮背景透明与半透明_图片背景透明

    Button或者ImageButton的背景设为透明或者半透明 半透明<Button android:background="#e0000000" ... />  透明 ...

  5. Android设置按钮透明

    <Button android:id="@+id/bt3" android:layout_width="163dp" android:layout_hei ...

  6. android imageview按钮按下动画效果

    private ImageView today_eat: today_eat = (ImageView) view.findViewById(R.id.today_eat); today_eat.se ...

  7. Android selector item 属性大全(按钮按下不同效果)

    <selector>         必须.必须是根元素.包含一个或多个<item>元素.          Attributes:             xmlns:and ...

  8. android 控件: xml 设置 Button 按下背景

    本篇文章讲述了不使用java代码来改变 Button 按下和未按下时的背景. 首先准备两张图片, 分别是按钮按下和按钮未按下的. 在res/drawable 文件夹中创建一个button_select ...

  9. iOS小技巧 - 为按钮设置不同状态下的背景色

    我们知道直接在Storyboard中设置按钮的背景色是不能根据不同状态来更改的,那问题来了,如果我们需要在不同的状态下(比如按钮没有被按下或者被按下),使得按钮呈现不同的背景色怎么办? 比如上图左边是 ...

随机推荐

  1. Github Blog 搭建手册

    http://www.ilehao.com/blog/2012/11/11/github-blog-config/ http://www.freebuf.com/articles/web/25613. ...

  2. windows中使用Git工具连接GitHub(配置篇)

    Git在源码管理领域目前占很大的比重了,而且开源的项目很多都转到GitHub上面了.例如:jQuery, reddit, Sparkle, curl, Ruby on Rails, node.js,  ...

  3. android 背景透明度渐变动画

    button.setVisibility(View.VISIBLE); // 背景透明度渐变动画 ObjectAnimator alpha = ObjectAnimator.ofFloat(butto ...

  4. Windows Azure 自动伸缩已内置

     WindowsAzure平台提供的主要优点之一是能够在有需要时快速缩放云中的应用程序以响应波动.去年7月以前,您必须编写自定义脚本或使用其他工具(如Wasabi或MetricsHub)来启用自动 ...

  5. HDU 5773 The All-purpose Zero(树状数组)

    [题目链接] http://acm.hdu.edu.cn/showproblem.php?pid=5773 [题目大意] 给出一个非负整数序列,其中的0可以替换成任意整数,问替换后的最长严格上升序列长 ...

  6. Apple Catching(dp)

    Apple Catching Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 9831   Accepted: 4779 De ...

  7. 【c语言】推断一个数是不是2的n次方

    // 推断一个数是不是2的n次方 #include <stdio.h> void judge_n(int a) { int b = a - 1; if ((a & b) == 0) ...

  8. ios蓝牙开发(三)app作为外设被连接的实现

    再上一节说了app作为central连接peripheral的情况,这一节介绍如何使用app发布一个peripheral,给其他的central连接 还是这张图,central模式用的都是左边的类,而 ...

  9. ceph启动脚本

    放在/etc/init.d/目录下,用法如下: root@u253:~# /etc/init.d/ceph === mon.a === usage: /etc/init.d/ceph [options ...

  10. 读取excel出现空值

    表格里某列假如混杂了数字和字符就会有可能部分读取为空,连接Excel方法如下 string strConn = 'Provider=Microsoft.Jet.OLEDB.4.0;' 'Data So ...