Can't figure out a way to have a centered TextView with vertically centered horizontal lines on either sides, stretched to the left and right end of the screen. Like on this picture below.

Any insight would help!
Finally came up with this solution that does exactly what is required
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/light_grey"
android:layout_gravity="center_vertical"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/add_heading_description"
android:textSize="@dimen/add_headings"
android:textColor="@color/dark_grey"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:layout_gravity="center"
android:background="@color/white"
/>
</FrameLayout>
I am having problem with the accepted answer, so sharing my way:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="0dp"
android:orientation="horizontal">
<View
android:layout_width="40dp"
android:layout_height="1dp"
android:background="@color/secondary_text"
android:layout_gravity="center_vertical"
android:layout_weight="1"/>
<Button
android:layout_width="20dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@null"
android:text="@string/Or"
android:clickable="false"
android:textColor="@color/secondary_text" />
<View
android:layout_width="40dp"
android:layout_height="1dp"
android:background="@color/secondary_text"
android:layout_gravity="center_vertical"
android:layout_weight="1"/>
</LinearLayout>

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With