Skip to content Skip to sidebar Skip to footer

How To Place A Text Between Two Straight Line Android?

I need to place a text between a straight line. I tried by using view but textview comes below the line. How to solve this? My code is as follows:

Solution 1:

<RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical|center_horizontal"
        android:layout_marginTop="10dp" >

        <View
            android:layout_width="wrap_content"
            android:layout_height="2dp"
            android:layout_centerVertical="true"
            android:layout_toRightOf="@+id/orText"
            android:background="#c0c0c0" />

        <TextView
            android:id="@+id/orText"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:layout_centerHorizontal="true"
            android:text="OR"
            android:textColor="@android:color/black" />

        <View
            android:layout_width="wrap_content"
            android:layout_height="2dp"
            android:layout_centerVertical="true"
            android:layout_toLeftOf="@+id/orText"
            android:background="#c0c0c0" />
    </RelativeLayout>

enter image description here


Post a Comment for "How To Place A Text Between Two Straight Line Android?"