In the above pictures we can see that the lines the paragraph is starting from the most start of the page (aligned start). and in the first picture the lines of paragraph also end of the page (aligned end).
so this is i want with my TextView
, showing in the second picture but i don't know what to do :(

- 292
- 4
- 17
-
2This might help you...https://stackoverflow.com/questions/1292575/android-textview-justify-text – AgentP May 20 '20 at 11:04
-
1margin, padding is not working for this so with the help of @PraveenSP 's comment i found a library to justify the text with github library. – Stackoverflower May 20 '20 at 13:25
3 Answers
There are two key elements to solve the problem you are currently facing: margin
and padding
.
Here's a basic difference between them:
Padding separates a view's contents from the boundaries of that view.
Margin separates a view from the immediate parent.
Here's a potential solution:
The image above has a significant margin (left and right) and a little padding. Therefore, you need to adjust the following attributes:
padding_start
padding_end
margin_start
margin_end
Also, remember to set the gravity
of the TextView to center.
To learn more about the difference between margin and padding, check this out.

- 6,086
- 10
- 44
- 69
Use this sample:
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:justificationMode="inter_word" />
This is the command: android:justificationMode="inter_word"

- 83
- 4
There are two ways in Kotlin until this time:
This feature is introduced in Android version >= 8.0.
1- XML
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:justificationMode="inter_word"
/>
2- Programmatically in an Activity:
Android O offers full justification
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
TextView.setJustificationMode(LineBreaker.JUSTIFICATION_MODE_INTER_WORD);}
However, Android Studio mentions that you can use it for Android Q , but is still works in Android O

- 2,653
- 18
- 24