Can I set property of Textview like justify?
No, you can't set the property like gravity. But still you can set the justification to your text by taking webview instead of text view.
You may refer to this.
What I understand from your question is, you want to know, how to set the alignment of text inside a TextView. You can align text in TextView to left, right, or center.
To do it from your layout (XML) file, use the following attribute in your layout file;
android:gravity=alignment
where,
alignment can be
- left to align text to left
- right to align text to right
- center to center the text
To do the same from code, use the following;
TextView textRegion = (TextView) findViewById(R.id.textRegion);
textRegion.setGravity(gravity);
where,
gravity =
Gravity.LEFT to align to left
Gravity.RIGHT to align to right
Gravity.CENTER to center the text
Note that, justify is not available yet for text alignment in TextView.
Update as of Android 8 (Oreo, API Level 26):
Justification is now possible but look quite jagged at right end.
See setJustificationMode