【开源】Material Ripple Layout

Material Ripple Layout

  •  https://github.com/balysv/material-ripple

    介绍:

    让指定View显示Material Ripple 效果的控件。很多Ripple效果都只针对一种特定的View,但是Material Ripple Layout可以通过简单的代码让任何view都显示Ripple效果。

    运行效果:

  •  

    使用说明:

    在代码中:

    1
    2
    3
    MaterialRippleLayout.on(view)
               .rippleColor(Color.BLACK)
               .create();

    或者直接将需要ripple效果的view放在MaterialRippleLayout的内部

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    <com.balysv.materialripple.MaterialRippleLayout
        android:id="@+id/ripple"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <Button
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:text="Button inside a ripple"/>
    </com.balysv.materialripple.MaterialRippleLayout>

    可以设置下列属性:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    app:rippleOverlay="true"              // if true, ripple is drawn in foreground; false - background
    app:rippleColor="#ff0000"             // color of ripple
    app:rippleAlpha="0.1"                 // alpha of ripple
    app:rippleDimension="10dp"            // radius of hover and starting ripple
    app:rippleHover="true"                // if true, a hover effect is drawn when view is touched
    app:rippleInAdapter="true"            // if true, MaterialRippleLayout will optimize for use in AdapterViews
    app:rippleDuration="350"              // duration of ripple animation
    app:rippleFadeDuration="75"           // duration of fade out effect on ripple
    app:rippleDelayClick="true"           // if true, delays calls to OnClickListeners until ripple effect ends
    app:rippleBackground="#FFFFFF"        // background under ripple drawable; used with rippleOverlay="false"
    app:ripplePersistent="true"           // if true, ripple background color persists after an

     

    如果你是想用在AdapterView中,需要将rippleInAdapter设置为true

posted on 2015-04-01 15:55  wasdchenhao  阅读(618)  评论(0)    收藏  举报

导航