开发者

Justify Text in TextView Android [closed]

开发者 https://www.devze.com 2023-01-26 23:38 出处:网络
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.

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 question

How 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

Justify Text in TextView Android [closed]


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:

Justify Text in TextView Android [closed]

Hope this helps. If you have any difficulties write back.- Thanks

0

精彩评论

暂无评论...
验证码 换一张
取 消