1

I have created an xml dotted line as explained in How do I make a dotted/dashed line in Android?. If I use it as the background of my TextView it shows up.

<TextView
    android:id="@+id/segment"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/dotted_lines"
    android:gravity="left"
    android:text="First segment"
    android:textSize="12sp" />

But if I use it as an accompanying drawable, it does not show up.

<TextView
    android:id="@+id/segment"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:drawableBottom="@drawable/dotted_lines"
    android:gravity="left"
    android:text="First segment"
    android:textSize="12sp" />

Essentially, I couldn't care less either way, except: I need the dotted lines to appear below the text in the TextView. Please help.

Community
  • 1
  • 1
Cote Mounyo
  • 13,817
  • 23
  • 66
  • 87
  • 1
    I think this might help you..http://stackoverflow.com/questions/10020466/android-4-0-sub-title-section-label-styling?lq=1 – Ritesh Gune Aug 10 '13 at 06:39

2 Answers2

3

Use following code to make textview with dotted line. Create file in drawable folder named dotted.xml

<shape xmlns:android="http://schemas.android.com/apk/res/android"
       android:shape="rectangle">

    <stroke
        android:color="#F59C51"
        android:width="2dp"
        android:dashGap="1dp"
        android:dashWidth="2dp"/>
</shape>

Then set in as background of textview like below.

<TextView
    android:id="@+id/segment"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:background="@drawable/dotted"
    android:gravity="left"
    android:text="First segment"
    android:textSize="12sp" />
Jitesh Dalsaniya
  • 1,917
  • 3
  • 20
  • 36
0
Try this. i think textview height might cause problem for you.
    <TextView
        android:id="@+id/segment"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:drawableBottom="@drawable/dotted_lines"
        android:gravity="left"
        android:text="First segment"
        android:textSize="12sp" />
Brijesh Patel
  • 676
  • 1
  • 5
  • 13