enter image description hereI have an Android Application . i have a page called Terms and Conditions.. the page is called from the web service . the text are not justified . how to justify the text ?
Asked
Active
Viewed 91 times
0
-
1are you showing the text contained in html in a webview ? – Alberto Cappellina Oct 24 '16 at 15:00
-
i am showing the text contained in a text view which is called from a web service – Abhijeet Mohapatra Oct 24 '16 at 15:08
-
the text is in html – Abhijeet Mohapatra Oct 24 '16 at 15:16
2 Answers
1
Android doesn't support text justification. The only thing you can do is apply android:gravity="center"

Diego Laballos
- 137
- 8
0
I'm assuming you're using XML layout.
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="YOURTEXT"
/>
add android:gravity="center"
OR add yourTextview.setGravity(Gravity.CENTER);
in JAVA
If you have text with HTML tags then you can use this like,
yourTextview.setText(Html.fromHtml("<h2>Title</h2><br><p>Description here</p>"));

Ganesh Pokale
- 1,538
- 1
- 14
- 28
-
my android:text= " " is blank and the text is called from a service – Abhijeet Mohapatra Oct 24 '16 at 15:17
-
-
if you want really hurt yourself, you can try this one: http://stackoverflow.com/questions/2116162/how-to-display-html-in-textview I think you should probably set
to block mode with css
– Alberto Cappellina Oct 24 '16 at 15:21 -
if yu get textview from webservice no problem... remove android:text="YOURTEXT" from xml and add yourTextview.setText(YourTextFromService); – Ganesh Pokale Oct 24 '16 at 15:30
-
-
check out the image i have posted in the question .. i want that page justified touching both sides of the screen – Abhijeet Mohapatra Oct 24 '16 at 17:31
-
-
if you are using "Html.fromHtml" this code in Java then remove android:gravity="center" – Ganesh Pokale Oct 24 '16 at 18:05
-
i removed ..now the left side is justified but right hand site its uneven – Abhijeet Mohapatra Oct 24 '16 at 18:19
-
-
public void doPostExecuteForCommu(JSONObject jsonObject) { // TODO Auto-generated method stub if(jsonObject!=null){ //{"status":1} try { – Abhijeet Mohapatra Oct 24 '16 at 19:00
-
String desc=jsonObject.getString("termcond"); termsofservice.setText(Html.fromHtml(desc)); } catch (JSONException e) { e.printStackTrace(); } – Abhijeet Mohapatra Oct 24 '16 at 19:00