NewUser
NewUser

Reputation: 21

Why custom drawable not showing in android

TextView is added to the screen

<TextView
        android:id="@+id/eventDetail_SpecialInfos"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginEnd="16dp"
        android:layout_marginStart="16dp"
        android:layout_marginTop="4dp"
        android:fontFamily="@font/source_sans_pro"
        android:text="Special Info"
        android:drawableBottom="@drawable/information_underline"
        android:textColor="@color/colorBlack"
        android:textSize="14dp" />

information_underline drawable is :

<stroke
    android:width="20dp"
    android:color="@color/colorBlack" />

Upvotes: 0

Views: 177

Answers (2)

Gabriele Mariotti
Gabriele Mariotti

Reputation: 363479

Check the @Suraj answer.
An alternative could be to use a TextInputLayout in the Material Component Library with a OutlinedBox style.

Something like:

<com.google.android.material.textfield.TextInputLayout
    style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
    ..>

    <com.google.android.material.textfield.TextInputEditText
        ../>

</com.google.android.material.textfield.TextInputLayout>

enter image description here

Upvotes: 1

Suraj Bahadur
Suraj Bahadur

Reputation: 3928

Drawable you have created is not the right way to do that and use the below code to draw anything in bottom of textview

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle" >

    <size
        android:height="1dp"
        android:width="100dp" />

    <solid android:color="@android:color/black" />

</shape>

Upvotes: 0

Related Questions