Skip to content Skip to sidebar Skip to footer

Android Layout Like Legend And Fieldset

I have a design requirement to show a part as shown in the figure. I have tried the following XML

Solution 1:

Try this out:

<LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:orientation="horizontal" ><Viewandroid:id="@+id/lineLeft"android:layout_width="0dp"android:layout_height="1dp"android:layout_margin="10dp"android:layout_weight="1"android:background="#b8b8b8" /><TextViewandroid:id="@+id/link_to_register"android:layout_width="wrap_content"android:layout_height="wrap_content"android:gravity="center"android:text="register_label"android:textColor="#525252"android:textSize="20sp" /><Viewandroid:id="@+id/lineRight"android:layout_width="0dp"android:layout_height="1dp"android:layout_margin="10dp"android:layout_weight="1"android:background="#b8b8b8" /></LinearLayout>

Solution 2:

Try this:

<RelativeLayoutandroid:layout_width="match_parent"android:layout_height="match_parent"android:orientation="horizontal" ><Viewandroid:id="@+id/lineLeft"android:layout_height="1dip"android:layout_width="25dp"android:layout_marginBottom="10dp"android:background="#b8b8b8" /><TextViewandroid:id="@+id/link_to_register"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_centerInParent="true"android:text="@string/register_label"android:textColor="#525252"android:textSize="20sp" /><Viewandroid:id="@+id/lineRight"android:layout_height="1dip"android:layout_width="25dp"android:layout_marginBottom="10dp"android:background="#b8b8b8" /></RelativeLayout>

You could also replace layout_centerInParent with layout_centerHorizontal to get the text in the center top.

Post a Comment for "Android Layout Like Legend And Fieldset"