If you want to show some drawables, Create a Shape
drawable as line. i.e. Name below file as dashed_line.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="line">
<stroke android:dashWidth="3dp" android:dashGap="1dp" android:color="@color/black" android:width="2dp"/>
</shape>
and use it as below:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@drawable/dashed_line">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@color/white"
android:text="@string/hello_blank_fragment"/>
</LinearLayout>
Or If you simply want to put as a string, '------' on both side then just add it dynamically while setting text i.e.
String display="display";
textview.setText("---------"+display+"--------");