0
텍스트 파일을 사용하여 텍스트를 가져 오는 앱이 있습니다. 텍스트를 가져 와서 Textview에 파일을 읽어 텍스트 뷰에 추가하면 제대로 작동하지만 텍스트에 형식을 추가하고 싶습니다. 머리말을 그렇게 대담하게 만드는 것.텍스트 파일의 텍스트를 Android의 텍스트 뷰로 포맷하는 방법
private void openFile()
{
String tema = "Message";
TextView temas = (TextView) findViewById(R.id.tutorial);
temas.setText(title);
temas.setTextSize(25);
temas.setTextColor(ContextCompat.getColor(this, R.color.colorPrimaryDark));
try {
InputStream is = getAssets().open("tutorials/tutorial1.txt");
int size = is.available();
byte[] buffer = new byte[size];
is.read(buffer);
is.close();
String text = new String(buffer);
TextView tv = (TextView) findViewById(R.id.text);
tv.setText(text);
tv.setTextSize(20);
tv.setTextColor(Color.parseColor("#000000"));
} catch (IOException e) {
throw new RuntimeException(e);
}
}
예,하지만 텍스트 파일에는 작동하지 않습니다. –