0

I am trying this but it does not work for me

 Paint p = new Paint();
 p.setColor(ContextCompat.getColor(textView.getContext(),android.R.color.holo_red_dark));
 textView.setPaintFlags(p.getColor());
 textView.setPaintFlags(Paint.UNDERLINE_TEXT_FLAG);
Sathish Kumar J
  • 4,280
  • 1
  • 20
  • 48
avais khan
  • 43
  • 1
  • 7
  • 4
    [Changing the underline color of TextView](http://stackoverflow.com/questions/30716673/changing-the-underline-color-of-textview) – Ravi Jul 04 '16 at 11:17

3 Answers3

0

try this way,

Paint p = new Paint();
p.setColor(ContextCompat.getColor(this,android.R.color.holo_red_dark));
p.setflags(Paint.UNDERLINE_TEXT_FLAG);
textView.setPaintFlags(p.getFlags());

for more see this question.

Community
  • 1
  • 1
V-rund Puro-hit
  • 5,518
  • 9
  • 31
  • 50
0
edittext.getBackground().setColorFilter(color, PorterDuff.Mode.SRC_IN);
Sohail Zahid
  • 8,099
  • 2
  • 25
  • 41
0

Create a under_line.xml file into drawable folder then set your textview background like this android:background="@drawable/under_line"

add this xml in your drawable folder uder_line.xml

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:bottom="-15dp">
    <rotate xmlns:android="http://schemas.android.com/apk/res/android"
        android:fromDegrees="0"
        android:pivotX="0.5"
        android:pivotY="0.5"
        android:toDegrees="0">
        <shape android:shape="line">
            <stroke
                android:width="1dp"
                android:color="@android:color/holo_red_dark" />
        </shape>
    </rotate>
</item></layer-list>

Then set your layout text view background like this

android:background="@drawable/under_line"

Hari Haran
  • 1,543
  • 4
  • 13
  • 25