listview中item改变默认点击样式
listview中item改变默认点击样式
listview中的item们默认点击后变成黄颜色,这次我们自定义该样式,将背景色改为绿色
在drawable下新建一个customer.xml
customer.xml
<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_pressed="true"> <color android:color="#76EE00"/> </item> <item android:state_pressed="false"> <color android:color="#000000"/> </item> </selector>
然后再listview的item.xml中设置背景色,android:background
item.xml
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="@drawable/customer" android:orientation="horizontal" > <ImageView android:id="@+id/image" android:layout_width="50dp" android:layout_height="50dp" android:src="@android:drawable/ic_delete" android:layout_gravity="center_vertical" /> <TextView android:id="@+id/text" android:layout_width="match_parent" android:layout_height="wrap_content" android:textSize="25sp" android:text="alsjdalksj" android:layout_gravity="center_vertical" /> </LinearLayout>
相关推荐
chenjinlong 2020-02-19
83580494 2013-07-19
langjiao 2013-07-16
kiduo0 2013-07-10
gongzhiyao0 2010-11-15
bigdatazx 2010-11-05
Urchindong 2011-08-01
peixiaopao 2011-08-21
MeOrdinary 2014-05-13
magic00 2019-10-21
guizhongyun 2011-09-27
csuhanshuai 2015-03-30
Sunanang 2015-03-30
snailbing 2015-04-23
huohu00 2015-04-22
toperfect 2015-07-01
nickey 2012-01-29
Rgenxiao 2012-01-26
满城风絮 2011-12-03