drawable/imagebutton.xml
<?xml version="1.0" encoding="utf-8"?>
<selector
xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_focused="true"
android:state_pressed="false"
android:drawable="@drawable/btnfocused" />
<item
android:state_focused="true"
android:state_pressed="true"
android:drawable="@drawable/btnfocusedpressed" />
<item
android:state_focused="false"
android:state_pressed="true"
android:drawable="@drawable/btnpressed" />
<item android:drawable="@drawable/btndefault" />
</selector>
然后,在main.xml 中将advancedbutton 赋值给Button 组件中background 的属性。
layout/main.xml
<Button
android:id="@+id/myButton1"
android:background="@drawable/ imagebutton "
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/str_button1"
/>
android ui imagebutton
定制ImageButton样式
最新推荐文章于 2025-07-25 10:51:45 发布
本文介绍如何使用XML定义ImageButton的样式,并将其应用于Button组件中,通过不同的状态显示不同的背景。
1334

被折叠的 条评论
为什么被折叠?



