因此,对于大文本,我使用ScrollingMovementMethod()。但是有一个问题,当按下文本滚动时,文本变为灰色。可以修复吗?
的.java
public class Knowledge extends Activity {
Button back, newText;
TextView TVHeading, TV;
void newText() {
Random rand = new Random();
int n = rand.nextInt(10) + 1;
String text = "knw" + n;
String resourceId = getResources().getString(
getResources().getIdentifier(text, "string", getPackageName()));
String[] knowledgeArray = resourceId.split("\n");
TVHeading.setText(knowledgeArray[0]);
TV.setText(knowledgeArray[1]);
}
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.knowledge);
back = (Button) findViewById(R.id.backKnowledge);
newText = (Button) findViewById(R.id.newText);
TVHeading = (TextView) findViewById(R.id.knowledgeTVHeading);
TV = (TextView) findViewById(R.id.knowledgeTV);
TV.setMovementMethod(new ScrollingMovementMethod());
newText();
back.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
newText.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
newText();
}
});
}
}
答案 0 :(得分:1)
尝试为textView
属性使用纯色,如下所示:
android:textColor="#000000"
android:textColorHighlight="#000000"