Comments (13)
It is because your words are too long. What you can try to do is increase the font size. Make sure to use DocumentView.FORMATTED_TEXT
.
from textjustify-android.
Here is my java :
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//DocumentView documentView = (DocumentView) findViewById(R.id.doc_view1);
DocumentView documentView = new DocumentView(this, DocumentView.FORMATTED_TEXT);
documentView.getDocumentLayoutParams().setHyphenator(new Hyphenator(HyphenPattern.PT));
documentView.getDocumentLayoutParams().setHyphenated(true);
}
}
But still get the same result.
Thank you.
Bunthoeun
from textjustify-android.
Your words are too long. Give me a day or two to add support for this.
—
Sent from Mailbox
On Mon, Jan 19, 2015 at 2:18 AM, Bunthoeun [email protected]
wrote:
Here is my java :
public class MainActivity extends Activity {
@OverRide
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//DocumentView documentView = (DocumentView) findViewById(R.id.doc_view1);
DocumentView documentView = new DocumentView(this, DocumentView.FORMATTED_TEXT);
documentView.getDocumentLayoutParams().setHyphenator(new Hyphenator(HyphenPattern.PT));
documentView.getDocumentLayoutParams().setHyphenated(true);}
}
But still get the same result.
Thank you.Bunthoeun
Reply to this email directly or view it on GitHub:
#57 (comment)
from textjustify-android.
Yes thank you so much. I can give some string: សៀវភៅដំបូងដែលគ្រឹះស្ថាន «ប្រភពប្រាជ្ញា» បានបោះពុម្ពនោះ គឺជាស្នាដៃរបស់អ្នកនិពន្ធ ប៉ែន តារាឫទ្ធិ ដែលជាការបកស្រាយអំពីកណ្ឌអេភេសូរ។ ទោះបើអ្នកប្រាជ្ញខាងគម្ពីរ និង អ្នកនិពន្ធរូបនេះ បានចែកឋានប៉ុន្មានអាទិត្យមុនពេល ដែលសៀវភៅនេះបានចែកចាយក៏ដោយ ក៏ស្នាដៃរបស់អ្នកនិពន្ធ ប៉ែន តារាឫទ្ធិ នៅតែដក់ជាប់ក្នុងចិត្តមនុស្សគ្រប់ជំនាន់ តាមរយៈសៀវភៅនេះដែរ។ បច្ចុប្បន្ននេះ «ប្រភពប្រាជ្ញា» មានទីតាំងនៅផ្ទះលេខ១១អា ផ្លូវលេខ២០០២ សង្កាត់ទឹកថ្លា ខណ្ឌសែនសុខ រាជធានីភ្នំពេញ។ មានបុគ្គលិកពេពេលជាជនជាតិខ្មែរ១១នាក់ សុទ្ធសឹងតែជាអ្នកមានជំនាញខ្ពស់ក្នុងវិស័យបោះពុម្ពផ្សាយ។ នោះជានិមិត្តចុងក្រោយរបស់លោកស្ទីវចំពោះ «ប្រភពប្រាជ្ញា» ដែលចង់ឃើញគ្រីស្ទបរិស័ទខ្មែរ ដឹកនាំពន្ធ័កិច្ចបោះពុម្ពផ្សាយដ៏សំខាន់នេះឆ្ពោះទៅពេលអនាគតដោយប្រសិទ្ធភាព។
from textjustify-android.
@bpbunthoeun You can build your custom hyphenator for this. This way it will break the words at the right places. If you use the built in SqueezeHyphenator
, then your words should fit better into one line. Make sure to use DocumentView.PLAIN_TEXT
in order to achieve this and update to version 2.0.6
documentView.getDocumentLayoutParams().setTextAlignment(TextAlignment.JUSTIFIED);
documentView.getDocumentLayoutParams().setHyphenator(SqueezeHyphenator.getInstance());
documentView.getDocumentLayoutParams().setHyphenated(true);
If you are having trouble, refer to CustomHyphenatorTest. Let me know how this goes for you. In the event, you don't like this hyphenator, you can build your own Hyphenator, just extend IHyphenator
from textjustify-android.
Dear Mathew, Thanks you very much for you answer, But I just get some error when use this DocumentView documentView = addDocumentView(new StringBuilder()
.append(getResources().getString(R.string.zero_spacing))
.toString(), DocumentView.PLAIN_TEXT);. I got red color on addDocumentView.
Here is my full java I just tries to copy your example come to test how it going:
package com.cambobox.documentview;
import android.app.Activity;
import android.os.Bundle;
import com.bluejamesbond.text.DocumentView;
import com.bluejamesbond.text.hyphen.SqueezeHyphenator;
import com.bluejamesbond.text.style.TextAlignment;
public class MainActivity extends Activity {
@OverRide
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
DocumentView documentView = addDocumentView(new StringBuilder()
.append(getResources().getString(R.string.zero_spacing))
.toString(), DocumentView.PLAIN_TEXT);
documentView.getDocumentLayoutParams().setTextAlignment(TextAlignment.JUSTIFIED);
documentView.getDocumentLayoutParams().setHyphenator(SqueezeHyphenator.getInstance());
documentView.getDocumentLayoutParams().setHyphenated(true);
}
}
Thank you hope you are don't mind I'm not good in code. :)
from textjustify-android.
It should look more like this:
package com.cambobox.documentview;
import android.app.Activity;
import android.os.Bundle;
import com.bluejamesbond.text.DocumentView;
import com.bluejamesbond.text.hyphen.SqueezeHyphenator;
import com.bluejamesbond.text.style.TextAlignment;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// set layout
setContentView(R.layout.activity_main);
// text you want
String text = "សៀវភៅដំបូងដែលគ្រឹះស្ថាន «ប្រភពប្រាជ្ញា» បានបោះពុម្ពនោះ គឺជាស្នាដៃរបស់អ្នកនិពន្ធ ប៉ែន តារាឫទ្ធិ ដែលជាការបកស្រាយអំពីកណ្ឌអេភេសូរ។ ទោះបើអ្នកប្រាជ្ញខាងគម្ពីរ និង អ្នកនិពន្ធរូបនេះ បានចែកឋានប៉ុន្មានអាទិត្យមុនពេល ដែលសៀវភៅនេះបានចែកចាយក៏ដោយ ក៏ស្នាដៃរបស់អ្នកនិពន្ធ ប៉ែន តារាឫទ្ធិ នៅតែដក់ជាប់ក្នុងចិត្តមនុស្សគ្រប់ជំនាន់ តាមរយៈសៀវភៅនេះដែរ។ បច្ចុប្បន្ននេះ «ប្រភពប្រាជ្ញា» មានទីតាំងនៅផ្ទះលេខ១១អា ផ្លូវលេខ២០០២ សង្កាត់ទឹកថ្លា ខណ្ឌសែនសុខ រាជធានីភ្នំពេញ។ មានបុគ្គលិកពេពេលជាជនជាតិខ្មែរ១១នាក់ សុទ្ធសឹងតែជាអ្នកមានជំនាញខ្ពស់ក្នុងវិស័យបោះពុម្ពផ្សាយ។ នោះជានិមិត្តចុងក្រោយរបស់លោកស្ទីវចំពោះ «ប្រភពប្រាជ្ញា» ដែលចង់ឃើញគ្រីស្ទបរិស័ទខ្មែរ ដឹកនាំពន្ធ័កិច្ចបោះពុម្ពផ្សាយដ៏សំខាន់នេះឆ្ពោះទៅពេលអនាគតដោយប្រសិទ្ធភាព។";
// create DocumentView
DocumentView documentView = new DocumentView(this, DocumentView.PLAIN_TEXT);
// set the properties
documentView.getDocumentLayoutParams().setTextColor(0xffffffff);
documentView.getDocumentLayoutParams().setTextTypeface(Typeface.DEFAULT);
documentView.getDocumentLayoutParams().setTextSize(14);
documentView.getDocumentLayoutParams().setTextAlignment(TextAlignment.JUSTIFIED);
documentView.getDocumentLayoutParams().setInsetPaddingLeft(30f);
documentView.getDocumentLayoutParams().setInsetPaddingRight(30f);
documentView.getDocumentLayoutParams().setInsetPaddingTop(30f);
documentView.getDocumentLayoutParams().setInsetPaddingBottom(30f);
documentView.getDocumentLayoutParams().setLineHeightMultiplier(1f);
documentView.getDocumentLayoutParams().setHyphenator(SqueezeHyphenator.getInstance());
documentView.getDocumentLayoutParams().setHyphenated(true);
// set text
documentView.setText(text)
// ****************** you have to edit this ******************
((SomeLayout) findViewById(R.id.some_layout)).addView(documentView)
}
}
from textjustify-android.
OK This is my Java screenshot:
from textjustify-android.
Ok. I provided u with the code in my last post. Try that out.
—
Sent from Mailbox
On Tue, Jan 20, 2015 at 11:40 PM, Bunthoeun [email protected]
wrote:
OK This is my Java screenshot:
Reply to this email directly or view it on GitHub:
#57 (comment)
from textjustify-android.
Thank you but please tell me what should I edit in your code? this is my XML :
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.bluejamesbond.text.DocumentView
xmlns:ext="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/dc_view1"
ext:documentView_textAlignment="justified"
ext:documentView_textFormat="plain"
ext:documentView_textSubPixel="true">
</com.bluejamesbond.text.DocumentView>
</LinearLayout>
from textjustify-android.
"Unfortunately, Document View has stopped" this is the message that I got when I run on my phone. and this some code that I edited
// ****************** you have to edit this ******************
((DocumentView) findViewById(R.id.dc_view1)).addView(documentView);
}
Thank you..
from textjustify-android.
You should study more about Android, but I will help you here.
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:paddingTop="15dp"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/main_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
MainActivity.java
package com.cambobox.documentview;
import android.app.Activity;
import android.os.Bundle;
import com.bluejamesbond.text.DocumentView;
import com.bluejamesbond.text.hyphen.SqueezeHyphenator;
import com.bluejamesbond.text.style.TextAlignment;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// set layout
setContentView(R.layout.activity_main);
// text you want
String text = "សៀវភៅដំបូងដែលគ្រឹះស្ថាន «ប្រភពប្រាជ្ញា» បានបោះពុម្ពនោះ គឺជាស្នាដៃរបស់អ្នកនិពន្ធ ប៉ែន តារាឫទ្ធិ ដែលជាការបកស្រាយអំពីកណ្ឌអេភេសូរ។ ទោះបើអ្នកប្រាជ្ញខាងគម្ពីរ និង អ្នកនិពន្ធរូបនេះ បានចែកឋានប៉ុន្មានអាទិត្យមុនពេល ដែលសៀវភៅនេះបានចែកចាយក៏ដោយ ក៏ស្នាដៃរបស់អ្នកនិពន្ធ ប៉ែន តារាឫទ្ធិ នៅតែដក់ជាប់ក្នុងចិត្តមនុស្សគ្រប់ជំនាន់ តាមរយៈសៀវភៅនេះដែរ។ បច្ចុប្បន្ននេះ «ប្រភពប្រាជ្ញា» មានទីតាំងនៅផ្ទះលេខ១១អា ផ្លូវលេខ២០០២ សង្កាត់ទឹកថ្លា ខណ្ឌសែនសុខ រាជធានីភ្នំពេញ។ មានបុគ្គលិកពេពេលជាជនជាតិខ្មែរ១១នាក់ សុទ្ធសឹងតែជាអ្នកមានជំនាញខ្ពស់ក្នុងវិស័យបោះពុម្ពផ្សាយ។ នោះជានិមិត្តចុងក្រោយរបស់លោកស្ទីវចំពោះ «ប្រភពប្រាជ្ញា» ដែលចង់ឃើញគ្រីស្ទបរិស័ទខ្មែរ ដឹកនាំពន្ធ័កិច្ចបោះពុម្ពផ្សាយដ៏សំខាន់នេះឆ្ពោះទៅពេលអនាគតដោយប្រសិទ្ធភាព។";
// create DocumentView
DocumentView documentView = new DocumentView(this, DocumentView.PLAIN_TEXT);
// set the properties
documentView.getDocumentLayoutParams().setTextColor(0xffffffff);
documentView.getDocumentLayoutParams().setTextTypeface(Typeface.DEFAULT);
documentView.getDocumentLayoutParams().setTextSize(14);
documentView.getDocumentLayoutParams().setTextAlignment(TextAlignment.JUSTIFIED);
documentView.getDocumentLayoutParams().setInsetPaddingLeft(30f);
documentView.getDocumentLayoutParams().setInsetPaddingRight(30f);
documentView.getDocumentLayoutParams().setInsetPaddingTop(30f);
documentView.getDocumentLayoutParams().setInsetPaddingBottom(30f);
documentView.getDocumentLayoutParams().setLineHeightMultiplier(1f);
documentView.getDocumentLayoutParams().setHyphenator(SqueezeHyphenator.getInstance());
documentView.getDocumentLayoutParams().setHyphenated(true);
// set text
documentView.setText(text)
// add to layout
((LinearLayout) findViewById(R.id.main_layout)).addView(documentView)
}
}
from textjustify-android.
Yes, thank you very much you.. it is working ..... 👍
from textjustify-android.
Related Issues (20)
- How to set RTL for Arabic Text
- Extra space in AlertDialog
- max line limit HOT 1
- com.bluejamesbond.text.StringDocumentLayout$PlainDocumentException: Cannot fit word(s) into one line. Font size too large? HOT 2
- is Html text Support ?
- bug java.lang.IllegalArgumentException:
- How to change the text size? HOT 3
- java.lang.IndexOutOfBoundsException HOT 2
- Crash on Android 7.X
- DocumentViews in LinearLayout and EventListeners
- Background Color does not change with Spannables, please help.
- DocumentView has a problem with ExpandableListView
- RTL supprot for documentView_textFormat="plain"
- Broken on API 21 when change portrait to landscape positions
- Hyphenate license
- Image Span test does not work
- Report crash .onMeasure
- How to use android:ellipsize="end" attributes????
- bug: java.lang.IllegalArgumentException: width and height must be > 0
- onClick in Clickablespan is not work HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from textjustify-android.