-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
5 changed files
with
89 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
stickerview/src/main/java/miaoyongjun/stickerview/DrawableSticker.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package miaoyongjun.stickerview; | ||
|
||
import android.graphics.Canvas; | ||
import android.graphics.Rect; | ||
import android.graphics.drawable.Drawable; | ||
import android.support.annotation.NonNull; | ||
|
||
/** | ||
* Author: miaoyongjun | ||
* Date : 17/8/6 | ||
*/ | ||
|
||
public class DrawableSticker extends Sticker { | ||
private Drawable drawable; | ||
private Rect realBounds; | ||
|
||
public DrawableSticker(Drawable drawable) { | ||
this.drawable = drawable; | ||
realBounds = new Rect(0, 0, getWidth(), getHeight()); | ||
init(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight()); | ||
} | ||
|
||
@Override | ||
public void draw(@NonNull Canvas canvas) { | ||
canvas.save(); | ||
canvas.concat(getMatrix()); | ||
drawable.setBounds(realBounds); | ||
drawable.draw(canvas); | ||
canvas.restore(); | ||
} | ||
|
||
@Override | ||
public int getWidth() { | ||
return drawable.getIntrinsicWidth(); | ||
} | ||
|
||
@Override | ||
public int getHeight() { | ||
return drawable.getIntrinsicHeight(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters