Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TextViews with dividers in between them

I am trying to recrate following layout in android studio:

Preview image

Because i am preety new at android stuff, i first tryed with LinearLayout, and figured thath this probably wont be possible with it. Now i am trying with RelativeLayout i already created this block with color:

        <RelativeLayout
                android:layout_width="fill_parent"
                android:layout_height="80dp"
                android:background="@color/red_top">
        </RelativeLayout>

Now i want to ask how can i divide it like it is shown at the image 1 bar at top and 2 at the bottom in the same layout, and how can i put same borders?

like image 544
HyperX Avatar asked Aug 26 '13 13:08

HyperX


1 Answers

You can do this by using the following xml code:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/custom_toast_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="#CD96CD"
        android:text="TEXT" />

    <View
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:background="#000000" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:gravity="center"
            android:background="#CD96CD"
            android:text="TEXT" />

        <View
            android:layout_width="1dp"
            android:layout_height="fill_parent"
            android:background="#000000" />

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:gravity="center"
            android:background="#CD96CD"
            android:text="TEXT" />
    </LinearLayout>

</LinearLayout>
like image 69
Rishabh Srivastava Avatar answered Sep 22 '22 21:09

Rishabh Srivastava