For future references, here is a simple solution that resizes properly to the parent's width, and shows a continuous divider line.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="40dp">
<View android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_centerVertical="true"
android:layout_marginStart="40dp"
android:layout_marginEnd="8dp"
android:layout_toStartOf="@id/sep_text"
android:background="@android:color/black"/>
<TextView android:id="@+id/sep_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="misc"/>
<View android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_centerVertical="true"
android:layout_marginStart="8dp"
android:layout_marginEnd="40dp"
android:layout_toEndOf="@id/sep_text"
android:background="@android:color/black"/>
</RelativeLayout>
The text can be accessed by the sep_text
id.
The height has been fixed to 40dp
but could be changed to wrap_content
.