Justify Text in TextView Android [closed]
Questions must demonstrate a minimal understanding of the problem being solved. Tell us what you've tried to do, why it didn't work, and how it should work. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this questionHow do you get textview to be justified ? is it p开发者_运维百科ossible to get the solution? I have searched most of the forums but i didn't make it up. please help me out.
UPDATED
We have created a simple class for this. There are currently two methods to achieve what you are looking for. Both require NO WEBVIEW and SUPPORTS SPANNABLES.
LIBRARY: https://github.com/bluejamesbond/TextJustify-Android
SUPPORTS: Android 2.0 to 5.X
SETUP
// Please visit Github for latest setup instructions.
SCREENSHOT
Android doesn't support text justification, sorry. You can use android:gravity
attribute to align text to left or right or center etc, but you can't really justify it. The only option I guess is to use a WebView
to show text and then use CSS to get the text justified.
<RelativeLayout android:id="@+id/RelativeLayout01"
android:layout_height="wrap_content" android:layout_width="fill_parent">
<TextView android:id="@+id/TextView2" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="I'm TextView- Left" android:layout_alignParentLeft="true">
</TextView>
<TextView android:id="@+id/TextView1" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="I'm TextView- Right" android:layout_alignParentRight="true">
</TextView>
</RelativeLayout>
ScreenShot:
Hope this helps. If you have any difficulties write back.- Thanks
精彩评论