为Android Views提供Ripple效果封装:Material Ripple Layout

jopen 9年前

Material Ripple Layout这个项目为Android Views提供Ripple效果封装。

Demo Image

用法

Use static initializer on your View (see xml attributes below for customization)

MaterialRippleLayout.on(view)             .rippleColor(Color.BLACK)             .create();

Or wrap your View with MaterialRippleLayout in your layout file:

<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>    If using in an `AdapterView` you must set `rippleInAdapter` to `true`

Configure using xml attributes or appropriate setters in code:

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 animation, until setRadius(0) is called

项目主页:http://www.open-open.com/lib/view/home/1414571782903