1
我以編程方式將TextView添加到線性佈局。我可以看到背景圖片,但由於某種原因,文本從不顯示。有任何想法嗎?代碼如下:在TextView中添加以編程方式顯示沒有文字
TextView pointsTV = new TextView(getApplicationContext());
pointsTV.setText("Test Should Show");
pointsTV.setGravity(Gravity.CENTER);
pointsTV.setTextColor(android.R.color.white);
pointsTV.setPadding(0, 20, 0, 20);
pointsTV.setBackgroundResource(R.drawable.gamesummary_bottom);
pointsTV.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT));
ll.addView(pointsTV);
就是這樣! pointsTV.setTextColor(ColorStateList.valueOf(Color.WHITE));謝謝! – Graeme 2011-02-02 22:10:07