zoukankan      html  css  js  c++  java
  • Android设置简单的动画效果

    Android设置简单的动画效果

    默认中,Button是有动画效果的,但是TextView等却没有,简单设置其动画效果如下

    xml中添加

    android:background="?android:attr/selectableItemBackground" 背景效果
    android:foreground="?android:attr/selectableItemBackground" 前景效果

    这样便能简单设置了触碰效果

    android:background="?android:attr/selectableItemBackgroundBorderless"  <!--无边界涟漪效果-->
    android:background="?android:attr/selectableItemBackground"  <!--有边界涟漪效果-->
    
    

    foreground属性只能给控件和帧布局设置,其它的布局设置无效果

    也可以自己创建效果

    
    <?xml version="1.0" encoding="utf-8"?>
     
    <selector xmlns:android="http://schemas.android.com/apk/res/android">
     
        <item android:state_focused="true"  android:state_enabled="false" android:state_pressed="true" android:drawable="@drawable/abc_list_selector_disabled_holo_light" />
        <item android:state_focused="true"  android:state_enabled="false"                              android:drawable="@drawable/abc_list_selector_disabled_holo_light" />
        <item android:state_focused="true"                                android:state_pressed="true" android:drawable="@drawable/abc_list_selector_background_transition_holo_light" />
        <item android:state_focused="false"                               android:state_pressed="true" android:drawable="@drawable/abc_list_selector_background_transition_holo_light" />
        <item android:state_focused="true"                                                             android:drawable="@drawable/abc_list_focused_holo" />
        <item                                                                                          android:drawable="@android:color/transparent" />
    </selector>
    
    

    相关属性:

    
    android:state_selected 选中
    android:state_focused 获得焦点
    android:state_pressed 点击
    android:state_enabled 设置是否响应事件,指所有事件
    android:drawable 设置图片效果
    
    
    这是小睿的博客,如果需要转载,请标注出处啦~ヾ(≧▽≦*)o谢谢。
  • 相关阅读:
    Linux中find常见用法示例
    PHP写的异步高并发服务器,基于libevent
    Prototype原型模式
    抽象工厂模式
    工厂方法模式
    简单工厂模式
    记一次皮肤过敏
    Thread类线程结束会唤醒使用其对象做锁而睡眠的线程
    位运算符
    逻辑运算符
  • 原文地址:https://www.cnblogs.com/Yunrui-blogs/p/14938953.html
Copyright © 2011-2022 走看看