spannablestring - Lettrine and Justified text in Android TextView -


working on custom textview class :

  1. set text 'justified'

  2. use custom font , size 1rst letter (lettrine), align left, wrap rest of text around lettrine.

  3. the textview set inside scrollview.

here webview version of expected result :

        text = "<html><meta charset=\"utf-8\"><body>";         text+="<style type=\"text/css\">"         text+="@font-face {font-family: myfont;src: url(\"font/squac.ttf\")}"         text+="body {text-align: justify;margin:10px;}"         text+="#lettrine{margin:10px;width : 100%; font-size : 20px;}"         text+="#lettrine:first-letter {font-family : myfont;font-size : 100px;color : black;padding:0px;margin-right:5px;float : left;}"         text+="</style>";         text+=<div><p id=\"lettrine\">"+mystringtext +"</p></div>"; text+= "</body></html>"; 

or check fiddle : https://jsfiddle.net/dejord6f/

but don't want use webview.. now, justified alignment : first tried set textview gravity (center-vertical/horizontal), no success. searched githubs, , found interesting things like: https://github.com/ufo22940268/android-justifiedtextview

about lettrine : tried set first letter custom font spannablestring :

typeface mycustomfont = typeface.createfromasset(getassets(), "fonts/myfont.ttf"); spannablestring styledstring = new spannablestring("my lorem ipsum string"); styledstring.setspan(new typefacespan(mycustomfont.getstring()), 1, 2,0); string mytext = ""+styledstring; 

so ! first question : styledstring nor mytext doesn't show customfont, seems 'mycustomfont.getstring()' has not format. tried 'mycustomfont.getstyle()' no success. tried (inside fragment)

styledstring.setspan(new typefacespan(context.getassets()+"fonts/myfont.ttf"), 1, 2,0); 

with no success.. feel tired of trying things typefacespan section in developer.android doesn't talk custom fonts :d

secondly :styledstring spannablestring, wich doesn't work text (string) alignment class, , when try convert string (string mytext = ""+styledstring;) nothing works.

well, take webview option, great if give tips this... feel can done custom textview. !


Comments

Popular posts from this blog

sql server - Cannot query correctly (MSSQL - PHP - JSON) -

php - trouble displaying mysqli database results in correct order -

C++ Linked List -