mathew-kurian / TextJustify-Android

:page_facing_up: Android Text Full Jusiftication / Wrapping / Justify / Hyphenate - V2.0
https://github.com/bluejamesbond/TextJustify-Android/wiki
Apache License 2.0
1.86k stars 370 forks source link

Custom font is not running on my app #80

Open hasnain-ahmad opened 9 years ago

hasnain-ahmad commented 9 years ago

Hi Friend I have attach my project with below link.

http://www.mediafire.com/download/ggobgpzzxjc412m/CustomFontTest.zip

It shows me this error.

Process: com.example.xperts98.customfonttest, PID: 11279
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.xperts98.customfonttest/com.example.xperts98.customfonttest.MainActivity}: android.view.InflateException: Binary XML file line #11: Error inflating class com.bluejamesbond.text.DocumentView
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2314)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2388)
        at android.app.ActivityThread.access$800(ActivityThread.java:148)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1292)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:135)
        at android.app.ActivityThread.main(ActivityThread.java:5312)
        at java.lang.reflect.Method.invoke(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:372)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:901)at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:696)Caused by: android.view.InflateException: Binary XML file line #11: Error inflating class com.bluejamesbond.text.DocumentView

at android.view.LayoutInflater.createView(LayoutInflater.java:633) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743) at android.view.LayoutInflater.rInflate(LayoutInflater.java:806) at android.view.LayoutInflater.inflate(LayoutInflater.java:504) at android.view.LayoutInflater.inflate(LayoutInflater.java:414) at android.view.LayoutInflater.inflate(LayoutInflater.java:365) at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:249) at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:106)at com.example.xperts98.customfonttest.MainActivity.onCreate(MainActivity.java:17)at android.app.Activity.performCreate(Activity.java:5953) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1128) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2267)             at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2388)             at android.app.ActivityThread.access$800(ActivityThread.java:148)             at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1292)             at android.os.Handler.dispatchMessage(Handler.java:102)             at android.os.Looper.loop(Looper.java:135)             at android.app.ActivityThread.main(ActivityThread.java:5312)             at java.lang.reflect.Method.invoke(Native Method)             at java.lang.reflect.Method.invoke(Method.java:372)             at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:901)at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:696) Caused by: java.lang.reflect.InvocationTargetException at java.lang.reflect.Constructor.newInstance(Native Method) at java.lang.reflect.Constructor.newInstance(Constructor.java:288) at android.view.LayoutInflater.createView(LayoutInflater.java:607)             at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743)             at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)             at android.view.LayoutInflater.inflate(LayoutInflater.java:504)             at android.view.LayoutInflater.inflate(LayoutInflater.java:414)             at android.view.LayoutInflater.inflate(LayoutInflater.java:365)             at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:249)             at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:106)at com.example.xperts98.customfonttest.MainActivity.onCreate(MainActivity.java:17)at android.app.Activity.performCreate(Activity.java:5953)             at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1128)             at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2267)             at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2388)             at android.app.ActivityThread.access$800(ActivityThread.java:148)             at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1292)             at android.os.Handler.dispatchMessage(Handler.java:102)             at android.os.Looper.loop(Looper.java:135)             at android.app.ActivityThread.main(ActivityThread.java:5312)             at java.lang.reflect.Method.invoke(Native Method)             at java.lang.reflect.Method.invoke(Method.java:372)             at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:901)at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:696) Caused by: java.lang.RuntimeException: Font asset not found fonts/ProximaNova-Light.ttf at android.graphics.Typeface.createFromAsset(Typeface.java:190) at com.bluejamesbond.text.DocumentView.initDocumentView(DocumentView.java:315)at com.bluejamesbond.text.DocumentView.(DocumentView.java:107)             at java.lang.reflect.Constructor.newInstance(Native Method)             at java.lang.reflect.Constructor.newInstance(Constructor.java:288)             at android.view.LayoutInflater.createView(LayoutInflater.java:607)             at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743)             at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)             at android.view.LayoutInflater.inflate(LayoutInflater.java:504)             at android.view.LayoutInflater.inflate(LayoutInflater.java:414)             at android.view.LayoutInflater.inflate(LayoutInflater.java:365)             at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:249)             at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:106)             at com.example.xperts98.customfonttest.MainActivity.onCreate(MainActivity.java:17)at android.app.Activity.performCreate(Activity.java:5953)             at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1128)             at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2267)             at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2388)             at android.app.ActivityThread.access$800(ActivityThread.java:148)             at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1292)             at android.os.Handler.dispatchMessage(Handler.java:102)             at android.os.Looper.loop(Looper.java:135)             at android.app.ActivityThread.main(ActivityThread.java:5312)             at java.lang.reflect.Method.invoke(Native Method)             at java.lang.reflect.Method.invoke(Method.java:372)             at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:901)at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:696)

Please guide me to resolve this issue. Thanks and regards Hasnain Ahmad

mathew-kurian commented 9 years ago

Look at Binary XML file line #11:

hasnain-ahmad commented 9 years ago

Here is my xml code. On line #11 there is deceleration for DocumentView.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context=".MainActivity">

<com.bluejamesbond.text.DocumentView
    xmlns:ext="http://schemas.android.com/apk/res-auto"
    android:id="@+id/dv_activity_aboutus_abouteXpert"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    ext:documentView_cacheConfig="auto_quality"
    ext:documentView_antialias="true"
    ext:documentView_hyphen="-"
    ext:documentView_reverse="false"
    ext:documentView_textAlignment="justified"
    ext:documentView_textFormat="plain"
    ext:documentView_textSize="16sp"
    ext:documentView_textTypefacePath="fonts/ProximaNova-Light.ttf"
    ext:documentView_textSubPixel="true"
    ext:documentView_text="Web eXperts is in the business of Web Solutions, Since 1998. We are specialized in cutting edge websites with style, interactive Flash animation, high end multimedia, and robust database applications/e-commerce solutions. We design, deploy and manage web sites of the highest quality for forward-thinking clients that demand a return on their internet solutions investment. We can measurably drive sales, reduce manpower, improve communication and enable a higher level of collaboration between you and your customers.\n"
    />

Here is java code.

package com.example.xperts98.customfonttest;

import android.support.v7.app.ActionBarActivity; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem;

import com.bluejamesbond.text.DocumentView; import com.bluejamesbond.text.style.TextAlignment;

public class MainActivity extends ActionBarActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    DocumentView documentView = new DocumentView(this, DocumentView.PLAIN_TEXT);  // Support plain text
    documentView.getDocumentLayoutParams().setTextAlignment(TextAlignment.JUSTIFIED);

}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.menu_main, menu);
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    //noinspection SimplifiableIfStatement
    if (id == R.id.action_settings) {
        return true;
    }

    return super.onOptionsItemSelected(item);
}

}