Android 实现选中与非选中样式效果
                                                            生活随笔
收集整理的這篇文章主要介紹了
                                Android 实现选中与非选中样式效果
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.                        
                                ?
?
drawable文件
?
<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"><item android:drawable="@drawable/log_button_bgok" android:state_focused="true"/><item android:drawable="@drawable/log_button_bgok" android:state_pressed="true"/><item android:drawable="@drawable/log_button_bgok" android:state_selected="true"/><item android:drawable="@drawable/log_button_bgok" android:state_checked="true"/><item android:drawable="@drawable/log_button_bg"/></selector> <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"><item android:state_selected="false" android:drawable="@drawable/tab_my"/><item android:state_selected="true" android:drawable="@drawable/tab_my_pre"/> </selector>?
layout.xml引用
<ImageViewandroid:id="@+id/imagetest"android:layout_width="30dp"android:layout_height="30dp"android:src="@drawable/tabhost_center_shape" />activity 調(diào)用樣式
ImageView imageView; imageView =(ImageView)findViewById(R.id.imagetest); imageView.setSelected(true);總結(jié)
以上是生活随笔為你收集整理的Android 实现选中与非选中样式效果的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
                            
                        - 上一篇: /usr/lib/gcc/x86_64-
 - 下一篇: 35:字符串的展开