我在RelativeLayout中添加了一些名为" number_container"的文本视图,这是我的代码,但我什么也看不见,文字视图没有添加......
private void labelAnimation(){
TextView number = new TextView(getApplicationContext());
number.setGravity(Gravity.CENTER);
Typeface font = Typeface.createFromAsset(getAssets(), "fonts/Gang of Three.ttf");
number.setTypeface(font);
Random random = new Random();
int random_size = random.nextInt(170 - 30) + 30;
number.setTextSize(random_size);
number.setTextColor(000000);
int random_text = random.nextInt(10-1)+1;
number.setText(Integer.toString(random_text));
int random_width = random.nextInt(width_screen - 50) + 50;
int random_height = random.nextInt(height_screen - 50) + 50;
RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT);
lp.setMargins(random_width, random_height, 0, 0);
number.setLayoutParams(lp);
number_container.addView(number);
int random_delay = random.nextInt(800-100)+100;
final Handler animation_sun = new Handler();
animation_sun.postDelayed(new Runnable() {
@Override
public void run() {
labelAnimation();
}
}, random_delay);
}
我还尝试删除自定义字体,但效果不佳。 我该怎么办?
答案 0 :(得分:0)
我的问题是textView的颜色......
number.setTextColor(color.WHITE);