imageview使用selector设置按下抬起时不同的背景
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="@mipmap/image_top" />
<item android:state_pressed="false" android:drawable="@mipmap/image_top_hly" /></selector>
imageview布局
<ImageView android:id="@+id/top"
android:clickable="true" //注意要写这个,否则不起作用 app:layout_constraintTop_toTopOf="@id/direction_layout1" app:layout_constraintLeft_toLeftOf="@id/direction_layout1" app:layout_constraintRight_toRightOf="@id/direction_layout1" android:src="@drawable/top_selector_backgrand" android:layout_width="@dimen/dp_115" android:layout_height="@dimen/dp_45"/>
本文标题:imageview使用selector设置按下抬起时不同的背景
本文链接:https://www.haomeiwen.com/subject/rhqdwktx.html
网友评论