Blog coding and discussion of coding about JavaScript, PHP, CGI, general web building etc.

Tuesday, December 22, 2015

How do you underline a text in android xml?

How do you underline a text in android xml?


How do you underline a text in the xml file? there is not a selection in the textStlye please help?

Answer by George Artemiou for How do you underline a text in android xml?


If you are using a string resource xml file (supports HTML tags), it can be done using , and .

                This is an underline.          

If you want to underline something from code use:

TextView tv = (TextView) view.findViewById(R.id.tv);  SpannableString content = new SpannableString("Content");  content.setSpan(new UnderlineSpan(), 0, content.length(), 0);  tv.setText(content);  

Hope this helps

Answer by Bhavin for How do you underline a text in android xml?


      This is an underline.    

If it does not work then

  This is an underline.  

Because "<" could be a keyword at some time.

And for Displaying

TextView textView = (TextView) view.findViewById(R.id.textview);  textView.setText(Html.fromHtml(getString(R.string.your_string_here)));  

Answer by abh22ishek for How do you underline a text in android xml?


Use this:

TextView txt = (TextView) findViewById(R.id.Textview1);  txt.setPaintFlags(txt.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);  

Answer by Nepster for How do you underline a text in android xml?


First of all go to String.xml file

you can add any html attributes like , italic or bold or underline here.

              This is an underline.        

Answer by Anthone for How do you underline a text in android xml?


To complete Bhavin answer. For exemple, to add underline or redirection.

((TextView) findViewById(R.id.tv_cgu)).setText(Html.fromHtml(getString(R.string.upload_poi_CGU)));    conditions gnrales]]>  

and you can know compatible tag here : http://commonsware.com/blog/Android/2010/05/26/html-tags-supported-by-textview.html


Fatal error: Call to a member function getElementsByTagName() on a non-object in D:\XAMPP INSTALLASTION\xampp\htdocs\endunpratama9i\www-stackoverflow-info-proses.php on line 72

0 comments:

Post a Comment

Popular Posts

Powered by Blogger.