-
Notifications
You must be signed in to change notification settings - Fork 9
/
Custom native TextView
42 lines (36 loc) · 1.17 KB
/
Custom native TextView
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
import android.app.Activity;
import android.widget.FrameLayout;
import android.graphics.Color;
import android.view.ViewGroup.LayoutParams;
import android.view.Gravity;
import android.R;
import android.graphics.Color;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.graphics.Paint.Style;
import android.graphics.drawable.GradientDrawable;
Activity act;
FrameLayout fl;
public void onStart() {
act = this.getActivity();
GradientDrawable sd = new GradientDrawable();
sd.setShape(GradientDrawable.RECTANGLE);
sd.setColor(Color.GRAY);
sd.setStroke(8, Color.RED);
TextView tv = new TextView(act);
tv.setLayoutParams(new RelativeLayout.LayoutParams(500, 100));
tv.setBackgroundColor(Color.GRAY);
tv.setBackground(sd);
tv.setX(width/2-250);
tv.setY(height/2);
tv.setGravity(Gravity.CENTER);
tv.setTextColor(Color.WHITE);
//tv.setTextSize(32);
tv.setText ("Hello world");
fl = (FrameLayout)act.findViewById(R.id.content);
FrameLayout.LayoutParams params1 = new FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, Gravity.CENTER);
fl.addView(tv);
}
void setup() {
background(Color.BLUE);
}