Git Product home page Git Product logo

textjustify-android's Introduction

LIBRARY IS NO LONGER MAINTAINED

If you want to adopt + maintain this library, please drop me a message - [email protected]

Gittip Android Arsenal Build Status Maven Central
Logo

Android Full Justification

About

This library will provide you a way to justify text. It supports both plain text and Spannables. Additionally, the library can auto-hyphentate your displayed content (thanks to @muriloandrade).

Compatible for Android 2.2 to 5.X

Other Libraries

Screenshot

Preview

Demo

Imgur

#Recent 01/11/2015 ► Added support for very long documents with fading and progress listener
01/10/2015 ► Refractored / renamed classes
01/04/2015 ► Improved caching support which allows for smooth scrolling
01/02/2015 ► Added XML attributes for DocumentView

Wiki

For examples, tests, and API refer to the Android-TextJustify Wiki.

Install

Just add to your build.gradle

dependencies {
    compile 'com.github.bluejamesbond:textjustify-android:2.1.6'
}

Known Issues

Status Issues
CLOSED Scroll caching for very large documents i.e. > 4000 paragaphs
OPEN Add letter-spacing feature like CSS
OPEN Improve text strike-through
OPEN Improve text underline
CLOSED Support more features like TextView in terms of Paint settings

textjustify-android's People

Contributors

agap avatar alvaromgdev avatar bluejamesbond avatar klinker41 avatar luelue avatar mfietz avatar miladrasooli avatar muriloandrade avatar pouyadarabi avatar shayanpourvatan avatar soulkeykim avatar syhids avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

textjustify-android's Issues

Drawing is slow with lots of text

Can be resolved by using this:

setDrawingCacheEnabled(true);

@OverRide
protected void onDraw(Canvas canvas)
{
Bitmap cache = getDrawingCache();
if (cache != null) {
canvas.drawBitmap(cache, 0, 0, paint);
return;
}

            TextViewEx Draw Code

    }

Top padding doesn't work

currently top padding doesn't work with TextViewEx.java.

adding the following at line 159 of TextViewEx.java does provide a workaround, though its not perfect:

verticalOffset+=getPaddingTop();

I'm attaching screenshots with and without the workaround code.

no_workaround

Current code

with_workaround

Code with workaround added

can not support show a lot of chinese

when i test many chinese ,it can not show one word
my text is
String myText=" 是个特别基础的控件,只要有文本基本就少不了它。但是最近在,项目开发的过程中我发现存在很多局限性,其中最令我头疼的就是文本排版方面的问题。我们都知道在中文字对齐方式有靠左、靠右、居中、分散对齐等,但是中就偏偏没有分散对齐这个属性设置。这就导致了中一段文字会出现右边参差不齐的问题,中文由于每个字等宽看起来还不是特别糟糕,英文看起来就比较过分了。";
this program can't run normal and Into the dead cycle
can you help me find the progrom ,thanks
this is my code
TextViewEx tv=(TextViewEx)findViewById(R.id.textview1);
Typeface typeface=Typeface.createFromAsset(this.getAssets(), "fzcartoon.ttf");
tv.setTypeface(typeface);
tv.setText(myText,true);
tv.setTextSize(30);

Library not clear

To be honest, i've spent hours trying to find a way to make use of this library and to attached it to view.. it was so difficult, can you help on how?

I want to make use of ArticleBuilder(), so how do i make reference to view where i have this --> <com.bluejamesbond.text.DocumentView xmlns:document="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="+id/instruction" />

here is my java code

    a = new ArticleBuilder();
    a.append("WHO: Ebola Cases",
            false, new RelativeSizeSpan(2f), new StyleSpan(Typeface.BOLD))
            .append("<font color=0xFFC801>Sam Frizell</font><font color=0x888888> @Sam_Frizell  Oct. 25, 2014</font>",
                    false, new RelativeSizeSpan(0.8f), new StyleSpan(Typeface.BOLD))
            .append("In New York and New Jersey, governors Andrew Cuomo and Chris Christie have implemented controversial quarantines on all healthcare workers returning from West Africa after a doctor returning from Guinea contracted the disease and was diagnosed in New York.",
                    true, new RelativeSizeSpan(1f), new JustifiedSpan());

    DocumentView documentView = new DocumentView(getActivity(), R.id.instruction);  // Support spanned text
    documentView.setText(a); // Set to `true` to enable justification

Doing it this way generate error

Process: com.samsoft.cbc.studio, PID: 2834
java.lang.NullPointerException
        at com.bluejamesbond.text.DocumentView$MeasureTask.onPostExecute(DocumentView.java:729)
        at com.bluejamesbond.text.DocumentView$MeasureTask.onPostExecute(DocumentView.java:685)
        at android.os.AsyncTask.finish(AsyncTask.java:632)
        at android.os.AsyncTask.access$600(AsyncTask.java:177)
        at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:645)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:136)
        at android.app.ActivityThread.main(ActivityThread.java:5017)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:515)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
        at dalvik.system.NativeStart.main(Native Method)

Any Solution on how to relate the view and the java code together, if i'm not doing it right.. please let me know. Thanks

Last Line size get truncated

Hi,

Thanks for the wonderful library. I am using your library to justify the textview. Everything works perfect except the last line of the paragraph.. The last line characters are getting truncated ... Please help me to solve the issue.

OutOfMemory Error with DocumentView inside ListView

Hi Mathew Kurian,
I'm getting an OutOfMemory error on DocumentView when running the app on my tablet (Nexus10). It is odd because I tested it on weaker devices (HTC One V) and is working just fine. Is this a known issue?
screen shot 2015-02-04 at 8 10 32 pm

Text inside ScrollView not reaching to the end

When you put the TextViewEx inside a ScrollVIew the scroller doesnt show complete text, it leaves some behind, its like its not calculating the height properly.

This is the beggining of the textViewEx
screenshot 2014-05-03 17 03 00

This is the bottom, and the scroller its maxed out, and as you can see some of the text is missing.
screenshot 2014-05-03 17 03 18

OnPreDraw approach not working

TextJustifyUtils.run((TextView)this);

Does not set correct block text on the text view.

1
I would expect this call to compute a String/CharSequence
that has extra spaces set, such that a normal TextView shows
block text.
However it does not seem to do anything.

2
What does the origWidth parameter in "run(final TextView tv, float origWidth)"
mean? Is that supposed to hold tv.getWidth() ?

Upload to maven central?

Are you planning to upload this neat library to Maven Central? It would certainly make it more accessible for new developers to include the project with a one-liner in their gradle config. :)

DocumentView not scrolling

Using the library TextJustify-Android I am not able to make the DocumentView scrollable. The text is shown correctly, justified, however the lower part is cut of instead of making it scrollable. I tried to put the DocumentView in ScrollView but then the text was not even shown...

screen shot 2015-01-26 at 16 56 47

Khmer not support

Thank you so much for you library it is very helpful, but I got the problem when I use it with Khmer unicode. it doesn't working well. Can you please help me to to finger-out this problem.
Thank you.
Bunthoeun

screen shot 2015-01-19 at 2 55 13 pm
screenshot_2015-01-19-15-04-37

Line is truncated

screenshot_2015-01-05-02-21-56

The first line is truncated (The letter P is cut off) on API 15, lib 1.4

XML as follows:

<com.bluejamesbond.text.DocumentView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="xxx"
            android:textAppearance="@style/TextAppearance.AppCompat.Body1"
            document:antialias="true"
            document:textSubpixel="true"
            document:textAlignment="justified"
            document:textFormat="plain"
            document:textSize="@dimen/abc_text_size_body_1_material"
            document:textColor="@color/abc_primary_text_material_light"
            document:text="xxxx" />

Margin Space

Is there a parameter for left and right margin space in using TextJustify ?

Fatal Exception java.util.regex.PatternSyntaxException

E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.util.regex.PatternSyntaxException: In a character range [x-y], x is greater than y near index 15:
([^4.941744E-4])
^
at java.util.regex.Pattern.compileImpl(Native Method)
at java.util.regex.Pattern.compile(Pattern.java:407)
at java.util.regex.Pattern.(Pattern.java:390)
at java.util.regex.Pattern.compile(Pattern.java:381)
at java.lang.String.replaceFirst(String.java:1793)
at org.diktor.utils.TextJustify.justifyOperation(TextJustify.java:73)
at org.diktor.utils.TextJustify.justify(TextJustify.java:82)
at org.diktor.utils.TextJustify.run(TextJustify.java:26)

Spacing between words

Justify text working on every device. But in some lines spacing between words fine and in some lines so much spacing. So extra spacing not looks good. Any solution for this?

DocumentView in a row item of ListView is not triggering ListView.OnItemClick listener

Hi, I'm having some problems when using DocumentView in a row item, it makes the whole row item not clickable. I fixed this by android:descendantFocusability="blocksDescendants" on the RelativeLayout. The problem however is that selecting the DocumentView does not select the Row Item, unlike using a normal TextView does. Clicking outside the DocumentView does indeed trigger the Row Item. What I want to achieve is that clicking the DocumentView, selects the Row Item similar to how it works when I use a normal TextView. Is this an ongoing issue or I'm doing something wrong?

I'll be attaching my layout if that helps.
screen shot 2015-01-24 at 10 12 29 am

Hyphenation

Hi,
I saw you made some amazing improvements in the new version of TextJustify, including the hyphenation, congratulations.

Now I’m trying to implement this new version into my project but I’m facing an issue.

If I right understand, the new way to get texts hyphenatated is:

docView.getDocumentLayoutParams().setHyphenator(new Hyphenator(HyphenPattern.PT));
docView.getDocumentLayoutParams().setHyphenated(true);

This way, nothing happens, seems like LayoutParams.setHyphenator() method will always just return (without set).
So I made some changes in this method and have the hyphenator settled.

But now, I’m facing an Exception:

java.util.ConcurrentModificationException
at java.util.LinkedList$LinkIterator.next(LinkedList.java:124)
at com.bluejamesbond.text.DocumentLayout.measure(DocumentLayout.java:222)
at com.bluejamesbond.text.DocumentView.onMeasure(DocumentView.java:142) …

Let me know if you need more details. Thank you.

Toast triggering NullPointerException

While editing the DocumentView on Android Studio this errors are generated and there is no preview of the widget.

java.lang.NullPointerException
    at android.widget.Toast.makeText(Toast.java:255)
    at com.bluejamesbond.text.IDocumentLayout.<init>(IDocumentLayout.java:69)
    at com.bluejamesbond.text.StringDocumentLayout.<init>(StringDocumentLayout.java:50)
    at com.bluejamesbond.text.DocumentView$3.<init>(DocumentView.java:372)
    at com.bluejamesbond.text.DocumentView.getDocumentLayoutInstance(DocumentView.java:372)
    at com.bluejamesbond.text.DocumentView.initDocumentView(DocumentView.java:338)
    at com.bluejamesbond.text.DocumentView.<init>(DocumentView.java:107)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
    at org.jetbrains.android.uipreview.ViewLoader.createNewInstance(ViewLoader.java:413)
    at org.jetbrains.android.uipreview.ViewLoader.loadView(ViewLoader.java:105)
    at com.android.tools.idea.rendering.LayoutlibCallback.loadView(LayoutlibCallback.java:176)
    at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:207)
    at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:132)
    at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:806)
    at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:782)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:385)
    at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:400)
    at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:332)
    at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:350)
    at com.android.tools.idea.rendering.RenderService$5.compute(RenderService.java:708)
    at com.android.tools.idea.rendering.RenderService$5.compute(RenderService.java:697)
    at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:932)
    at com.android.tools.idea.rendering.RenderService.createRenderSession(RenderService.java:697)
    at com.android.tools.idea.rendering.RenderService.render(RenderService.java:816)
    at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager.doRender(AndroidLayoutPreviewToolWindowManager.java:646)
    at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager.access$1700(AndroidLayoutPreviewToolWindowManager.java:82)
    at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager$7$1.run(AndroidLayoutPreviewToolWindowManager.java:589)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl$2.run(ProgressManagerImpl.java:178)
    at com.intellij.openapi.progress.ProgressManager.executeProcessUnderProgress(ProgressManager.java:209)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:212)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.runProcess(ProgressManagerImpl.java:171)
    at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager$7.run(AndroidLayoutPreviewToolWindowManager.java:584)
    at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:320)
    at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:310)
    at com.intellij.util.ui.update.MergingUpdateQueue$2.run(MergingUpdateQueue.java:254)
    at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:269)
    at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:227)
    at com.intellij.util.ui.update.MergingUpdateQueue.run(MergingUpdateQueue.java:217)
    at com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:238)
    at com.intellij.util.Alarm$Request$1.run(Alarm.java:327)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

android.view.InflateException
    at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:136)
    at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:806)
    at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:782)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:385)
    at android.view.BridgeInflater.inflate(BridgeInflater.java:184)
    at android.widget.Toast.makeText(Toast.java:254)
    at com.bluejamesbond.text.IDocumentLayout.<init>(IDocumentLayout.java:69)
    at com.bluejamesbond.text.StringDocumentLayout.<init>(StringDocumentLayout.java:50)
    at com.bluejamesbond.text.DocumentView$3.<init>(DocumentView.java:372)
    at com.bluejamesbond.text.DocumentView.getDocumentLayoutInstance(DocumentView.java:372)
    at com.bluejamesbond.text.DocumentView.initDocumentView(DocumentView.java:338)
    at com.bluejamesbond.text.DocumentView.<init>(DocumentView.java:107)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
    at org.jetbrains.android.uipreview.ViewLoader.createNewInstance(ViewLoader.java:413)
    at org.jetbrains.android.uipreview.ViewLoader.loadView(ViewLoader.java:105)
    at com.android.tools.idea.rendering.LayoutlibCallback.loadView(LayoutlibCallback.java:176)
    at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:207)
    at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:132)
    at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:806)
    at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:782)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:385)
    at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:400)
    at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:332)
    at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:350)
    at com.android.tools.idea.rendering.RenderService$5.compute(RenderService.java:708)
    at com.android.tools.idea.rendering.RenderService$5.compute(RenderService.java:697)
    at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:932)
    at com.android.tools.idea.rendering.RenderService.createRenderSession(RenderService.java:697)
    at com.android.tools.idea.rendering.RenderService.render(RenderService.java:816)
    at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager.doRender(AndroidLayoutPreviewToolWindowManager.java:646)
    at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager.access$1700(AndroidLayoutPreviewToolWindowManager.java:82)
    at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager$7$1.run(AndroidLayoutPreviewToolWindowManager.java:589)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl$2.run(ProgressManagerImpl.java:178)
    at com.intellij.openapi.progress.ProgressManager.executeProcessUnderProgress(ProgressManager.java:209)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:212)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.runProcess(ProgressManagerImpl.java:171)
    at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager$7.run(AndroidLayoutPreviewToolWindowManager.java:584)
    at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:320)
    at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:310)
    at com.intellij.util.ui.update.MergingUpdateQueue$2.run(MergingUpdateQueue.java:254)
    at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:269)
    at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:227)
    at com.intellij.util.ui.update.MergingUpdateQueue.run(MergingUpdateQueue.java:217)
    at com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:238)
    at com.intellij.util.Alarm$Request$1.run(Alarm.java:327)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: android.view.InflateException: Binary XML file line #37: Error inflating class TextView
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:757)
    at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:128)
    ... 56 more
Caused by: java.lang.ClassNotFoundException: onCreateView
    at android.view.BridgeInflater.onCreateView(BridgeInflater.java:114)
    at android.view.LayoutInflater.onCreateView(LayoutInflater.java:682)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:741)
    ... 57 more
Caused by: android.view.InflateException: Binary XML file line #37: Error inflating class <unknown>
    at android.view.LayoutInflater.createView(LayoutInflater.java:633)
    at android.view.BridgeInflater.onCreateView(BridgeInflater.java:82)
    ... 59 more
Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.GeneratedConstructorAccessor61.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
    at android.view.LayoutInflater.createView(LayoutInflater.java:607)
    ... 60 more
Caused by: android.content.res.Resources$NotFoundException
    at com.android.layoutlib.bridge.android.BridgeContext.obtainStyledAttributes(BridgeContext.java:490)
    at android.content.res.Resources_Theme_Delegate.obtainStyledAttributes(Resources_Theme_Delegate.java:70)
    at android.content.res.Resources$Theme.obtainStyledAttributes(Resources.java:1393)
    at android.widget.TextView.<init>(TextView.java:682)
    at android.widget.TextView.<init>(TextView.java:629)
    at android.widget.TextView.<init>(TextView.java:625)
    ... 64 more

XML of my project

<com.bluejamesbond.text.DocumentView
        xmlns:ext="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        ext:documentView_antialias="true"
        ext:documentView_cacheConfig="auto_quality"
        ext:documentView_hyphen="-"
        ext:documentView_lineHeightMultiplier="2.0"
        ext:documentView_maxLines="100"
        ext:documentView_offsetX="10dp"
        ext:documentView_offsetY="10dp"
        ext:documentView_insetPadding="10dp"
        ext:documentView_insetPaddingBottom="10dp"
        ext:documentView_insetPaddingLeft="10dp"
        ext:documentView_insetPaddingRight="10dp"
        ext:documentView_insetPaddingTop="10dp"
        ext:documentView_reverse="false"
        ext:documentView_textAlignment="justified"
        ext:documentView_textColor="@android:color/white"
        ext:documentView_textFormat="plain"
        ext:documentView_textSize="12sp"
        ext:documentView_textStyle="bold|strikeThru|underline"
        ext:documentView_textSubPixel="true"
        ext:documentView_textTypefacePath="fonts/helvetica.ttf"
        ext:documentView_wordSpacingMultiplier="5.0" />

Arabic support

Hi, first of all thanks for sharing great work.
Let me show some issues related with arabic text:
1.We see that your justify logic is by adding spaces and fill free spaces in one row, but in arabic if you divide letters which related to one word, meaning is broken. So if we put arabic text, sometimes if one arabic word has space between letters your logic divide one word to parts.
2.In arabic text, words are being displayed correctly by meaning, but appearing from left to right not from right to left. How to fix that issue?

Inflating error on DocumentView

Hi,
I compile TextJustfy in gradle and then, I try to use the exactly xml DocumentView of the example. But when i run my project, it crash with an inflating class error in the DocumentView. Can you help me?

Setting text with spannable, wont update unless i click and drag on textview

private Spannable highlightString(String original, String search) {
    String rep = original;
    String newS = rep.replace(search, "<font color='red'>" + search + "</font>");
    ArticleBuilder amb = new ArticleBuilder();
    amb.append(
            newS
            , false, new RelativeSizeSpan(1f), new JustifiedSpan()
    );
    return amb;
    }

I am setting the text of my document view using the above which results in:

http://puu.sh/fepY7/a2edfbad2a.png

However, when i select a new line to highlight, NOTHING happens, setting the text view to ANY content, normal spannable string or otherwise, the view refuses to update, the only way i can get it to show the new value is to tap and drag on the view, how peculiar?

Thanks!

Not compiling

The current sources do not compile. TextJustifyUtils.createWrappedLine() has wrong signature and charCounter is not declared in TextViewEx.

Not working for spanned textview

SpannableStringBuilder sb = new SpannableStringBuilder();

    for (int i = 0; i < mArrayList.size(); i++) {
        if (i == pos) {

            int start = sb.length();
            sb.append(mArrayList.get(i).content);
            sb.setSpan(new BackgroundColorSpan(0xFFCCFFCC), start,
                    sb.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

        } else {
            sb.append(mArrayList.get(i).content);
        }
    }

my spanned text and it just display text..

Spannable TextView with different colors

Given the following program:

TextViewEx textView = (TextViewEx) findViewById(R.id.textView1);
textView.setText("", true);
Spannable span = Spannable.Factory.getInstance().newSpannable("Hello ");
span.setSpan(new ForegroundColorSpan(Color.RED), 0, span.length(),
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
span = Spannable.Factory.getInstance().newSpannable(" world!");
span.setSpan(new ForegroundColorSpan(Color.GREEN), 0, span.length(),
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

The output text is printed without any red or green color. Is there any way to solve the justifying of a TextViewEx with different styles?

IndexOutOfBoundsException while measuring...

Hello,
I have android 2.3.6 phone device. Sometimes I get IndexOutOfBoundsException on SpannableDocumentLayout class starting from the 230 line:
// Use the line-height of the next line
y += enableLineBreak * (-staticLayout.getLineAscent(lineNumber + 1) + staticLayout
.getLineDescent(lineNumber + 1));
I debug and see that error comes from staticLayout.getLineAscent(lineNumber + 1) part.

Prefix all the customs attrs

As you are using rather common custom attrs like text or textSize, theses attrs could conflict with another libraries.

As suggested by Xavier Ducrohet here, you should prefix all your custom attrs with something like tj_.

You could also consider using the platform attrs for common attrs like textSize, paddingetc...

Thanks

setTextSize value similar to TextView

Hi there,

I currently have both a textView and a documentView (from this library) which the user is allowed to choose the font size for. Unfortunately the documentView scales differently from the textView when using the setTextSize(float) function. Is there something I'm missing?

The project I'm working on can be found here.

Thanks for the library and your time.

Last character in new line

Hello i am facing a problem

i have the fallowing string.xml
SELLO HACE BIEN\n\n
Adicional al compromiso con los Principios del Pacto Global, Chova del Ecuador S.A., asume ciertos objetivos y planes de acción en las siguientes áreas:\n

  1. Obtención de certificaciones internacionales de calidad en procesos, medio ambiente y condiciones laborales.\n
  2. Implementación de un plan de Eficiencia Energética, para reducir los gastos por consumos de energía sin dejar de producir según lo planificado.\n
  3. Implementar un modelo de gestión de manejo de desechos en todas las áreas, tratando de generar la menor cantidad de desechos en cada uno de nuestros procesos. Se intentará reciclar la mayor cantidad de desechos provenientes de cada proceso.\n
  4. Ser considerados buenos vecinos en cualquier lugar donde estemos.\n
  5. Fomentar e impulsar la educación infantil, la salud y el buen vivir de la sociedad.\n\n
    Cada uno de los funcionarios de Chova del Ecuador S.A., se compromete a leer, entender y aplicar estos principios y objetivos de RSE, entendiendo que este compromiso empresarial cuenta con todo el apoyo de sus accionistas y alta gerencia.

in the attached image you will see the result
screenshot_2014-11-22-13-53-44

.jar not found

Hello sir, I have donload it but i could import it on eclipse.

java.lang.StringIndexOutOfBoundsException:

hello mates,

Thank you for this library. I am using this in our project. But i got crashed like below.

we use option one(1) to implement justify.

Device: Android 4.1 1 Device
Galaxy Core (arubaslim)

java.lang.StringIndexOutOfBoundsException: length=40; index=41 at java.lang.String.indexAndLength(String.java:589) at java.lang.String.substring(String.java:1448) at com.applogic.hajjguidebangla.TextViewEx.onDraw(TextViewEx.java:228) at android.view.View.draw(View.java:13614) at android.view.View.getDisplayList(View.java:12565) at android.view.View.getDisplayList(View.java:12609) at android.view.View.draw(View.java:13338) at android.view.ViewGroup.drawChild(ViewGroup.java:2990) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2860) at android.view.View.getDisplayList(View.java:12563) at android.view.View.getDisplayList(View.java:12609) at android.view.View.draw(View.java:13338) at android.view.ViewGroup.drawChild(ViewGroup.java:2990) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2860) at android.view.View.draw(View.java:13617) at android.widget.FrameLayout.draw(FrameLayout.java:467) at android.widget.ScrollView.draw(ScrollView.java:1825) at android.view.View.getDisplayList(View.java:12565) at android.view.View.getDisplayList(View.java:12609) at android.view.View.draw(View.java:13338) at android.view.ViewGroup.drawChild(ViewGroup.java:2990) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2860) at android.view.View.getDisplayList(View.java:12563) at android.view.View.getDisplayList(View.java:12609) at android.view.View.draw(View.java:13338) at android.view.ViewGroup.drawChild(ViewGroup.java:2990) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2860) at android.view.View.getDisplayList(View.java:12563) at android.view.View.getDisplayList(View.java:12609) at android.view.View.draw(View.java:13338) at android.view.ViewGroup.drawChild(ViewGroup.java:2990) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2860) at android.view.View.draw(View.java:13617) at android.support.v4.view.ViewPager.draw(ViewPager.java:2092) at android.view.View.getDisplayList(View.java:12565) at android.view.View.getDisplayList(View.java:12609) at android.view.View.draw(View.java:13338) at android.view.ViewGroup.drawChild(ViewGroup.java:2990) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2860) at android.view.View.draw(View.java:13617) at android.view.View.getDisplayList(View.java:12565) at android.view.View.getDisplayList(View.java:12609) at android.view.View.draw(View.java:13338) at android.view.ViewGroup.drawChild(ViewGroup.java:2990) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2860) at android.view.View.getDisplayList(View.java:12563) at android.view.View.getDisplayList(View.java:12609) at android.view.View.draw(View.java:13338) at android.view.ViewGroup.drawChild(ViewGroup.java:2990) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2860) at android.view.View.getDisplayList(View.java:12563) at android.view.View.getDisplayList(View.java:12609) at android.view.View.draw(View.java:13338) at android.view.ViewGroup.drawChild(ViewGroup.java:2990) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2860) at android.view.View.draw(View.java:13617) at android.widget.FrameLayout.draw(FrameLayout.java:467) at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:2458) at android.view.View.getDisplayList(View.java:12565) at android.view.View.getDisplayList(View.java:12609) at android.view.HardwareRenderer$GlRenderer.draw(HardwareRenderer.java:1187) at android.view.ViewRootImpl.draw(ViewRootImpl.java:2313) at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2185) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1993) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1143) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4674) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:725) at android.view.Choreographer.doCallbacks(Choreographer.java:555) at android.view.Choreographer.doFrame(Choreographer.java:525) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711) at android.os.Handler.handleCallback(Handler.java:615) at android.os.Handler.dispatchMessage(Handler.java:92) at android.os.Looper.loop(Looper.java:137) at android.app.ActivityThread.main(ActivityThread.java:4960) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805) at dalvik.system.NativeStart.main(Native Method)

Bold does not work ...

Hello I am giving spannable text to justify on FormattedTextTest class , but following to method calls I found that there is
public void setText(CharSequence text) {
this.text = text.toString();
this.textChange = true;
}
in DocumentLayout class that will destroy all spannable text settings and make it plain text. Or am I wrong somewhere?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.