介绍:
刮刮卡效果,支持刮文字和图片。
运行效果:
使用
ScratchImageView
XML
<com.cooltechworks.views.ScratchImageView android:id="@+id/sample_image" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@android:color/white" android:src="@drawable/img_sample2" />
JAVA
ScratchImageView scratchImageView = new ScratchImageView(this); scratchImageView.setRevealListener(new ScratchImageView.IRevealListener() { @Override public void onRevealed(ScratchImageView tv) { // on reveal } });
ScratchTextView
XML
<com.cooltechworks.views.ScratchTextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center|end" android:text="@string/flat_200" android:textSize="15sp" android:textStyle="bold" />
JAVA
ScratchTextView scratchTextView = new ScratchTextView(this); scratchTextView.setRevealListener(new ScratchTextView.IRevealListener() { @Override public void onRevealed(ScratchTextView tv) { //on reveal } });
引入工程
- Add the following configuration in your build.gradle file.
repositories { jcenter() maven { url "https://jitpack.io" } } dependencies { compile 'com.github.cooltechworks:ScratchView:v1.0' }