用shape结合selector实现点击效果

来源:互联网 发布:大学生网络诈骗ppt 编辑:程序博客网 时间:2024/05/29 21:31
  1. <span style="font-family: Arial, Helvetica, sans-serif;"><?xml version="1.0" encoding="UTF-8"?></span>  
  2. <shape xmlns:android="http://schemas.android.com/apk/res/android"  
  3.     android:shape="rectangle" >  
  4.   
  5.     <gradient  
  6.         android:angle="90"  
  7.         android:endColor="#ffff99"  
  8.         android:startColor="#ffff99" />  
  9.   
  10.     <corners android:radius="20dp" />  
  11.   
  12. </shape>  


[html] view plaincopy在CODE上查看代码片派生到我的代码片
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <shape xmlns:android="http://schemas.android.com/apk/res/android"  
  3.     android:shape="rectangle" >  
  4.   
  5.     <gradient  
  6.         android:angle="90"  
  7.         android:endColor="#cc3935"  
  8.         android:startColor="#cc3935" />  
  9.   
  10.     <corners android:radius="20dp" />  
  11.   
  12. </shape>  
[html] view plaincopy在CODE上查看代码片派生到我的代码片
  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <selector xmlns:android="http://schemas.android.com/apk/res/android">  
  3.   
  4.     <item android:drawable="@drawable/red_shape" android:state_pressed="true"/>  
  5.     <item android:drawable="@drawable/gray_shape"/>  
  6.   
  7. </selector>  
0 0
原创粉丝点击