一、依赖
compile 'com.ldoublem.thumbUplib:ThumbUplib:0.5'
二、布局
<com.ldoublem.thumbUplib.ThumbUpView android:id="@+id/tpv" android:layout_width="50dp" android:layout_height="50dp" app:cracksColor="#33475f" app:edgeColor="#9d55b8" app:fillColor="#ea8010" app:unlikeType="1"/>
三、代码 MainActivity
import android.graphics.Color; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.widget.Toast; import com.ldoublem.thumbUplib.ThumbUpView; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ThumbUpView mThumbUpView = (ThumbUpView) findViewById(R.id.tpv); mThumbUpView.setUnLikeType(ThumbUpView.LikeType.broken); mThumbUpView.setCracksColor(Color.rgb(22, 33, 44)); mThumbUpView.setFillColor(Color.rgb(11, 200, 77)); mThumbUpView.setEdgeColor(Color.rgb(33, 3, 219)); //判断是否点赞 mThumbUpView.setOnThumbUp(new ThumbUpView.OnThumbUp() { @Override public void like(boolean like) { if (like==true){ Toast.makeText(MainActivity.this,"点赞",Toast.LENGTH_SHORT).show(); }else{ Toast.makeText(MainActivity.this,"取消点赞",Toast.LENGTH_SHORT).show(); } } }); mThumbUpView.Like(); mThumbUpView.UnLike(); } }