zoukankan      html  css  js  c++  java
  • Andorid之使用ImageView和Selector配置文件制作多样式按钮(默认、点击、灰掉)

         在做地图的时候  有个需求:

         当可以缩放地图的时候,放大按钮可以使用。当不可以使用地图的时候,放大按钮不可以使用。放大按钮在默认状态下是一个背景,点击的状态下是另一个背景。

         废话少说,代码奉上:

        一、ImageView配置文件片段。

            

       <ImageView
        	android:id="@+id/ivZoomOut"
        	android:layout_height="wrap_content"
        	android:layout_width="wrap_content"
        	android:layout_marginRight="10px"
        	android:layout_marginBottom="10px"
        	android:src="@drawable/zoom_out_2"
        	/>
    

     二、样式控制配置文件zoom_out_2.xml:

      

    <?xml version="1.0" encoding="utf-8"?>
    <selector xmlns:android="http://schemas.android.com/apk/res/android">     
    <!-- Disabled -->
    	<item android:state_enabled="false" 
    	      android:state_pressed="false" 
    	      android:textColor="@color/red"
    		  android:drawable="@drawable/zoom_out_disable" />     
    <!-- Pressed -->
    	<item android:state_enabled="true" 
    	      android:state_pressed="true"
    		  android:textColor="@android:color/white" 
    		  android:drawable="@drawable/zoom_out_pressed" />     
    <!-- Focused -->
    <!-- 	<item android:state_enabled="true" 
    	      android:state_focused="true"
    		  android:textColor="@android:color/white" 
    		  android:drawable="@drawable/list_item_focused" /> -->     
    <!-- Default -->
    	<item android:state_enabled="true" 
    	      android:state_pressed="false" 
    	      android:drawable="@drawable/zoom_out_default"/>
    </selector> 
    

     三、代码控制:

      

     if(**){
               zoomOutView.setEnabled(false);
         }else{
              zoomOutView.setEnabled(true);
         }
    
  • 相关阅读:
    20180813 mysql 手动整理
    20180811 mysql 整理
    20180810 mysql
    20180808 第一阶段项目展示
    20180807 接近第一阶段项目完成 心里话
    20180730 轮播 (加定时器 鼠标移入停止 移除继续轮播 点击小图标换大图片)
    20180730 表格的删除 增加 编辑内容
    10.10日PHP MAC
    10.09日PHP MAC
    数据库类的封装
  • 原文地址:https://www.cnblogs.com/likehua/p/2516610.html
Copyright © 2011-2022 走看看