学Android的朋友们,对ImageButton一定不陌生。在自学Android的过程中,也用到了ImageButton,因此再次整理一下:
演示效果如下:
首先准备两张图片,用于点击ImageButton时背景图片的切换:
图片下载链接:http://www.easyicon.net/language.en/iconsearch/switch/
各部分具体代码如下:
界面布局activity_main.xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools