【问题标题】:Material Design Ripple/Stay Solid AnimationMaterial Design Ripple/Stay Solid 动画
【发布时间】:2015-01-17 02:53:51
【问题描述】:

有没有办法创建一个动画,一旦它起涟漪,当上下文操作栏被激活时它会保持纯色?

【问题讨论】:

    标签: android material-design rippledrawable


    【解决方案1】:

    我能够通过使用结合 statelistdrawable 的波纹动画成功地做到这一点,示例如下:

    Ripple.xml

     <?xml version="1.0" encoding="utf-8"?>
     <ripple xmlns:android="http://schemas.android.com/apk/res/android"
        android:color="@color/colorPrimary">
        <item android:id="@android:id/mask"
              android:drawable="@android:color/white" />
        <item android:drawable="@drawable/background_selector"/>
     </ripple>
    

    Background_Selector.xml

    <?xml version="1.0" encoding="utf-8"?>
    <selector xmlns:android="http://schemas.android.com/apk/res/android">
        <item android:state_activated="true" android:drawable="@color/colorPrimaryDark"/>
    </selector>
    

    【讨论】:

    • 好。我认为这是因为 Ripple Drawable 扩展了 LayerDrawable ,所以它可以工作!
    猜你喜欢
    • 2015-09-06
    • 1970-01-01
    • 2021-12-25
    • 2016-02-14
    • 1970-01-01
    • 1970-01-01
    • 2021-01-31
    • 2016-10-26
    • 2017-06-29
    相关资源
    最近更新 更多