0
テキストファイルを使用してテキストを取得するアプリがあります。私は、テキストを取得し、ファイルから読み込んでTextviewに追加することで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);
}
}
はい、ただし、テキストファイルでは機能しません –