android layout - DocumentView shows me error while using custom font -


friends using documentview justifying , using custom font in it. works fine justifying font when place path of custom font in it.it shows error me.

here project.

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

here error stack.

process: com.example.xperts98.customfonttest, pid: 11279 java.lang.runtimeexception: unable 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         @ android.app.activitythread.performlaunchactivity(activitythread.java:2314)         @ `enter code here`android.app.activitythread.handlelaunchactivity(activitythread.java:2388)         @ android.app.activitythread.access$800(activitythread.java:148)         @ android.app.activitythread$h.handlemessage(activitythread.java:1292)         @ android.os.handler.dispatchmessage(handler.java:102)         @ android.os.looper.loop(looper.java:135)         @ android.app.activitythread.main(activitythread.java:5312)         @ java.lang.reflect.method.invoke(native method)         @ java.lang.reflect.method.invoke(method.java:372)         @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:901)         @ 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         @ android.view.layoutinflater.createview(layoutinflater.java:633)         @ android.view.layoutinflater.createviewfromtag(layoutinflater.java:743)         @ android.view.layoutinflater.rinflate(layoutinflater.java:806)         @ android.view.layoutinflater.inflate(layoutinflater.java:504)         @ android.view.layoutinflater.inflate(layoutinflater.java:414)         @ android.view.layoutinflater.inflate(layoutinflater.java:365)         @ android.support.v7.app.appcompatdelegateimplv7.setcontentview(appcompatdelegateimplv7.java:249)         @ android.support.v7.app.appcompatactivity.setcontentview(appcompatactivity.java:106)         @ com.example.xperts98.customfonttest.mainactivity.oncreate(mainactivity.java:17)         @ android.app.activity.performcreate(activity.java:5953)         @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1128)         @ 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         @ java.lang.reflect.constructor.newinstance(native method)         @ java.lang.reflect.constructor.newinstance(constructor.java:288)         @ 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         @ android.graphics.typeface.createfromasset(typeface.java:190)         @ com.bluejamesbond.text.documentview.initdocumentview(documentview.java:315)         @ com.bluejamesbond.text.documentview.<init>(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) 

first have create “assets” folder in “main” folder using android studio wizard.

here picture illustrate procedure.

enter image description here

second have create ”fonts” folder under “assets” folder. here picture illustrate procedure. enter image description here

third have put font.ttf/font.otf file in fonts folder.

here activity_main.xml code.

<linearlayout 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:orientation="vertical"     tools:context=".mainactivity">      <textview         android:id="@+id/textview"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_gravity="center_horizontal"         android:text="@string/my_text"         android:textappearance="?android:attr/textappearancelarge" />   </linearlayout> 

here mainactivity.java code

package com.example.documentviewwithcustomfont;  import android.graphics.typeface; import android.support.v7.app.appcompatactivity; import android.os.bundle; import android.view.menu; import android.view.menuitem; import android.widget.textview;  import com.bluejamesbond.text.documentview; import com.bluejamesbond.text.style.textalignment;  public class mainactivity extends appcompatactivity {      textview textview;      @override     protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.activity_main);          textview = (textview) findviewbyid(r.id.textview);          documentview documentview = new documentview(this, documentview.plain_text);         documentview.getdocumentlayoutparams().settextalignment(textalignment.justified);          typeface font = typeface.createfromasset(getassets(), "fonts/proxima_nova_regular.ttf");          textview.settypeface(font);       }  } 

below link can download whole project.

http://www.mediafire.com/download/28726mwwhvua5nd/documentviewwithcustomfont.rar


Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -