2011-02-02 8 views
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); 

답변

0

색상을 숫자로 설정하면이 색상이 사라집니다. setTextColor()를 사용하기 위해

pointsTV.setBackgroundResource(android.R.color.white); 

를 사용하여, 당신은 그것을 statelist 또는 16 진수 대신에 색상 값을 제공해야합니다. The salient bit of the developer guide is here.

+1

그게 전부 였어! pointsTV.setTextColor (ColorStateList.valueOf (Color.WHITE)); 고맙습니다! – Graeme

관련 문제