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>

更多相关文章

  1. 几个activity跳转特效的实现
  2. ImageView的属性android:scaleType,即ImageView.setSca...
  3. android 呼入电话的监听(来电监听)转
  4. Android(安卓)如何加载大图片
  5. Android底部导航栏实现(四)之TabLayout+ViewPager
  6. Android(安卓)实现文件(图片)上传
  7. Android(安卓)图片加载库Glide
  8. android 自定义图片剪裁
  9. Android(安卓)DrawerLayout抽屉效果

随机推荐

  1. Android - 主要的UI元素
  2. [C#] 與Android共舞–手機post資料給Serv
  3. Android中巧妙的位运算
  4. EventBus粘性事件
  5. Android(安卓)GPS 定位的实现(2-1) 使用Goo
  6. Android--高级组件
  7. android随机生成验证码
  8. Android Studio SDK版本兼容问题,拷贝的A
  9. Android多核与单核的性能持平的问题
  10. Android 人脸识别+人脸匹配(OpenCV+JavaC