How to emphasize the text custom?

task

Closed due to the fact that the essence of the question is not clear to the participants of Vadizar , Air , Kromster , 0xdb , cheops 14 Apr '18 at 3:42 .

Try to write more detailed questions. To get an answer, explain what exactly you see the problem, how to reproduce it, what you want to get as a result, etc. Give an example that clearly demonstrates the problem. If the question can be reformulated according to the rules set out in the certificate , edit it .

  • 7
    The question is not related to android studio. - Drakonoved
  • does not have? why? I need to do this for android in android studio - Abl Baltabekov
  • one
    It does not have, because it is possible to develop under android without any android studio, and even without any other development environment. And to realize what is in the picture, you can a bunch of very different ways. - Peter Samokhin
  • one
    I think the person simply could not competently formulate the question, since it is far from the subject area. I believe that the stackoverflow community could prompt and explain what is wrong. - Timur Mukhortov
  • @pavlofff You are right. I saw your answers, they are really voluminous, high-quality and explain the essence of the problem, and of course it’s hard to answer the same thing every time. Is it possible to somehow improve the search system for similar questions? I think this is the main problem. Because With RecyclerView, a similar problem, answered one more question after 2 days. Specifically, this question, I have a suspicion that the person is not a developer and just decided to try to change something in his project .. I just assumed or did not know what IDE is - Timur Mukhortov

2 answers 2

There are three ways to do this:

  1. SpannableString
  2. setPaintFlags ()
  3. Html.fromHtml ()

1st method:

To underline text you use SpannableString

String udata="Underlined Text"; SpannableString content = new SpannableString(udata); content.setSpan(new UnderlineSpan(), 0, udata.length(), 0); mTextView.setText(content); 

2nd method:

You can use the SetPaintFlags method for a TextView to emphasize TextView text.

 mTextView.setPaintFlags(mTextView.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG); mTextView.setText("This text will be underlined"); 

3rd way:

Using Html.fromHtml (htmlString) ;

 String htmlString="<u>This text will be underlined</u>"; mTextView.setText(Html.fromHtml(htmlString)); 

or

 txtView.setText(Html.fromHtml("<u>underlined</u> text")); 

    at last he worked himself.

    deshed.xml

     <item> <shape android:shape="rectangle" > <solid android:color="@android:color/transparent" /> </shape> </item> <item android:gravity="center" android:width="65dp" android:height="5dp" > <shape> <solid android:color="@android:color/transparent" /> <stroke android:width="4dp" android:color="#ffd216" /> </shape> </item> 

    then just plug in xml android: drawableBottom = "@ drawable / dashed"

    • I started the current development on android. before this did not do. thanks for the answers - Abl Baltabekov