Android 刮刮卡 - ScratchView
介紹:
刮刮卡效果,支持刮文字和圖片。
運行效果:
使用
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
}
});</code></pre>
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
}
});</code></pre>
引入工程
- Add the following configuration in your build.gradle file.
repositories {
jcenter()
maven { url "
dependencies {
compile 'com.github.cooltechworks:ScratchView:v1.0'
}</code></pre>
本文由用戶 EliseKovar 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!