main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
<ImageButton android:src="@drawable/selector" android:layout_height="wrap_content" android:id="@+id/imageButton1" android:layout_width="wrap_content"></ImageButton>
<!-- android:src为图片地址 -->
</LinearLayout>
drawable目录下新建selector.xml
<?xml version="1.0" encoding="utf-8"?>
<selector
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"
android:drawable="@drawable/arrow_pressed" />
<!-- 按钮按下效果 arrow_pressed和arrow_normal 为图片文件名称 -->
<item android:state_focused="true"
android:drawable="@drawable/arrow_pressed" />
<!-- 按钮获取焦点效果 -->
<item android:drawable="@drawable/arrow_normal" />
<!-- 按钮默认效果 -->
</selector>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
<ImageButton android:src="@drawable/selector" android:layout_height="wrap_content" android:id="@+id/imageButton1" android:layout_width="wrap_content"></ImageButton>
<!-- android:src为图片地址 -->
</LinearLayout>
drawable目录下新建selector.xml
<?xml version="1.0" encoding="utf-8"?>
<selector
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"
android:drawable="@drawable/arrow_pressed" />
<!-- 按钮按下效果 arrow_pressed和arrow_normal 为图片文件名称 -->
<item android:state_focused="true"
android:drawable="@drawable/arrow_pressed" />
<!-- 按钮获取焦点效果 -->
<item android:drawable="@drawable/arrow_normal" />
<!-- 按钮默认效果 -->
</selector>
发表评论
-
startActivityForResult 简介
2011-03-29 15:55 1284依次打开Activity A1--A2--A3--A4 这时 ... -
startActivityForResult
2011-03-29 15:49 1146startActivityForResult 方法-- ... -
史上最全的Android的Tab与TabHost讲解
2011-03-28 11:22 1591Tab与TabHost 这就是Tab,而盛放Tab的 ... -
Android对话框
2011-03-25 11:21 1125Android 对话框(Dialog)大全 ... -
PreferenceActivity详解
2011-03-25 11:15 1442为了引入这个概率 首先从需求说起 即:现有某Activity专 ... -
TCP/UDP/HTTP
2011-03-25 11:09 1125先来一个讲TCP、UDP和HTTP ... -
9png
2011-03-25 11:08 1914今天学习了用9png图来优化横屏竖屏的UI,使用sdk自带的工 ... -
Notification
2011-03-25 11:07 939Android系统的状态栏(Status Bar)中有一个创新 ... -
一些技巧
2011-03-25 11:03 7871:查看是否有存储卡插入 String status=Envi ... -
布局像素单位
2011-03-25 11:03 827Android的layout文件中有时候可能会指定具体的单位, ... -
使用ActivityGroup来切换Activity和Layout
2011-03-25 11:02 1135在一个主界面中做Activity切换一般都会用TabActiv ... -
activitygroup
2011-03-25 11:01 1730说说tabhost和activitygroup 最近 ... -
线程
2011-03-25 11:01 1014今天在论坛上看到一些关于线程的帖子,我觉得与我理解的有些差异, ... -
类级框架
2011-03-25 11:00 744类集框架:Collection,Map,Iterator,En ... -
Intent打电话
2011-03-25 11:00 1217intent英文意思是意图,pending表示即将发生或来临的 ... -
Intent Uri
2011-03-25 10:59 1068进入联系人页面 1.Intent intent = new I ... -
Service
2011-03-25 10:59 940一、Service的概念 Service是Android程序中 ... -
Broadcast Receiver
2011-03-25 10:56 1948一、Broadcast Receiver简介 Android中 ... -
ContentProvider MIME类型
2011-03-25 10:55 1238Android程序的主要4部分 ... -
ContentProvider-1查询
2011-03-25 10:55 1237今天看了android的官方文档中ContentProvide ...
相关推荐
本资料主要涵盖了`ImageButton`的基本用法、属性设置以及在实际应用中的注意事项。 一、`ImageButton`基本用法 1. XML布局文件中添加`ImageButton`: 在布局文件中,可以通过`<ImageButton>`标签来声明一个`...
在Android应用开发中,`ImageButton`是一个非常重要的控件,它继承自`ImageView`,并且添加了点击事件的支持。这个`Android应用源码之(ImageButton图片按钮)`的压缩包提供了有关如何在Android应用中有效使用`...
本资料是关于`ImageButton`在实际应用中的源码分析,旨在帮助开发者更深入地理解其工作原理和使用技巧。 `ImageButton`在UI设计中扮演着重要角色,它可以用于创建各种交互式的按钮,如启动游戏、打开设置、切换状态...
在实际应用中,`ImageButton`可以结合`Drawable`的多种状态(如正常、按下、聚焦等)来实现更复杂的交互效果。例如,你可以为`ImageButton`设置不同的`Drawable`资源以适应不同状态: ```xml ``` 然后将这...
`ImageButton`的设计旨在提供一种更加直观和美观的用户交互方式,尤其是在UI设计中追求简洁和视觉吸引力的应用中。 ### 1. ImageButton的基本使用 创建`ImageButton`首先要在布局XML文件中定义它。基本语法如下: ...
综上,`Imagebutton`是Android UI设计中不可或缺的一部分,熟练掌握其用法和特性将有助于提升应用的用户体验和功能性。通过阅读源码、学习工具使用和资源优化,开发者能更好地应对各种复杂的界面设计挑战。
本资源提供了关于`ImageButton`的源码学习材料,旨在帮助开发者深入理解其工作原理,并能灵活应用于实际项目中。下面将详细探讨`ImageButton`的相关知识点。 1. **`ImageButton`的基本使用**: `ImageButton`与`...
2. **将状态列表资源应用到`ImageButton`**:在布局文件中,将刚才创建的状态列表资源设置为`ImageButton`的`src`属性。 ```xml <ImageButton android:id="@+id/my_image_button" android:layout_width="wrap_...
开发者可以参考这些示例,学习如何自定义和使用`ImageButton`来提升应用程序的用户体验。 总之,`WPF ImageButton`是一个功能强大的控件,它允许开发人员创建具有视觉吸引力的交互式按钮,同时提供丰富的定制选项,...
本话题聚焦于自定义一个通用的`ImageButton`组件,该组件结合了图像和按钮的功能,提供了更丰富的交互体验。在Flex4中实现这样的组件通常涉及到两个主要部分:组件类(Component Class)和皮肤类(Skin Class)。...
在.NET框架中,C#是一种常用的编程语言,用于构建各种应用程序,包括Windows桌面应用。自定义控件是C#编程中的一个重要概念,它允许开发者根据特定需求创建具有独特功能和外观的用户界面元素。本话题将深入探讨如何...
在许多应用界面设计中,我们经常需要为 `ImageButton` 设置不同的图片以实现不同的功能状态,例如:按下时显示一张图片,弹起时显示另一张图片,以提供更直观的用户反馈。下面我们将详细讨论如何在Android中实现`...
这个"Android ImageButton图片按钮Demo源码.rar"应该包含了一个完整的示例项目,用于演示如何在Android应用中使用`ImageButton`。 首先,我们来详细了解一下`ImageButton`的基本用法。`ImageButton`主要通过设置其`...
在Windows Forms应用开发中,创建具有视觉吸引力的用户界面是至关重要的。`ImageButton`控件是一种常见的元素,它结合了图像和按钮的功能,为用户提供直观的交互方式。本篇文章将详细探讨`ImageButton`的实现,特别...
在Android应用开发中,UI设计是至关重要的,而自定义控件可以让我们更灵活地实现独特的界面效果。本教程将深入探讨如何...在DemoCustomView-ImageButton项目中,你可以找到实际的代码示例,进一步理解并应用这些概念。
这篇文章将深入探讨`ImageButton`控件的特性和使用方法,帮助你更好地理解和应用这个控件。 一、`ImageButton`控件的基本属性 1. `Image`属性:此属性用于设置显示在`ImageButton`上的图像。你可以加载本地图片...
Android ImageButton 背景图片的切换 Android ImageButton 背景图片的切换是一个常见的交互设计,旨在实现按钮的状态变化。...这种技术可以广泛应用于 Android 开发中,例如在音乐播放器中实现播放暂停按钮的切换。
在Android应用开发中,`ImageButton`是一个非常重要的控件,它继承自`ImageView`,但增加了点击事件的支持,使得开发者可以实现类似按钮的功能,同时展示图片。本篇将深入探讨在Android 4.0(API Level 14)环境下...
总的来说,自定义imagebutton控件通过GDI+编程提供了一种灵活的方式来呈现视觉效果,它可以更好地融入到应用程序的UI设计中。开发者可以根据需求调整其行为,如添加鼠标悬停效果、按下状态变化等,以增强用户体验。...