Material 旋压favorite/star 按纽:Material Favorite Button
jopen
9年前
Material 旋压favorite/star 按纽
Gradle
allprojects { repositories { jcenter() maven { url "https://jitpack.io" } } } dependencies { compile 'com.github.ivbaranov:MaterialFavoriteButton:0.1.1' }
Usage
Declare in XML (see xml attributes below for customization):
<com.github.ivbaranov.mfb.MaterialFavoriteButton android:layout_width="wrap_content" android:layout_height="wrap_content" />
Or static initializer (see xml attributes below for customization):
MaterialFavoriteButton favorite = new MaterialFavoriteButton.Builder(this) .create();
Configure using xml attributes or setters in code:
app:mfb_animate_favorite="true" // to animate favoriting app:mfb_animate_unfavorite="false" // to animate unfavoriting app:mfb_padding="12" // image padding app:mfb_favorite_image="@drawable/ic_fav" // custom favorite resource app:mfb_not_favorite_image="drawable/ic_not_fav"// custom not favorite resource app:mfb_rotation_duration="400" // rotation duration app:mfb_rotation_angle="360" // rotation angle app:mfb_bounce_duration="300" // bounce duration app:mfb_color="black" // black or white default resources app:mfb_type="star" // star or heart shapes