-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStickerTextView.java
72 lines (59 loc) · 2.05 KB
/
StickerTextView.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package com.greentown.emmarpublicity.stickerview;
import android.content.Context;
import android.graphics.Color;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import com.greentown.emmarpublicity.stickerview.util.AutoResizeTextView;
// This is modified code by Me(@pranavagiligar), originally developed my cheungchingai
public class StickerTextView extends StickerView{
private AutoResizeTextView tv_main;
public StickerTextView(Context context) {
super(context);
}
public StickerTextView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public StickerTextView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
@Override
public View getMainView() {
if(tv_main != null)
return tv_main;
tv_main = new AutoResizeTextView(getContext());
//tv_main.setTextSize(22);
tv_main.setTextColor(Color.WHITE);
tv_main.setGravity(Gravity.CENTER);
tv_main.setTextSize(400);
tv_main.setShadowLayer(4, 0, 0, Color.BLACK);
tv_main.setMaxLines(1);
LayoutParams params = new LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT
);
params.gravity = Gravity.CENTER;
tv_main.setLayoutParams(params);
if(getImageViewFlip()!=null)
getImageViewFlip().setVisibility(View.GONE);
return tv_main;
}
public void setText(String text){
if(tv_main!=null)
tv_main.setText(text);
}
public String getText(){
if(tv_main!=null)
return tv_main.getText().toString();
return null;
}
public static float pixelsToSp(Context context, float px) {
float scaledDensity = context.getResources().getDisplayMetrics().scaledDensity;
return px/scaledDensity;
}
@Override
protected void onScaling(boolean scaleUp) {
super.onScaling(scaleUp);
}
}