anon
anon

Reputation:

Put Action Bar like line above buttons and line between two buttons

Currently I having some trouble putting a thin line between my two buttons and a line above both of them similar to the one from the action bar.

Right now my buttons looks like this:

enter image description here

I am trying to get this:

enter image description here

Not exactly sure what to do. I am trying to implement this but no luck:

android how to make some space between buttons and make white line above each of them

Here is my xml file:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:id="@+id/layout"
              android:orientation="vertical"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent">




    <Button
    android:id="@+id/block_button"
    style="?android:attr/borderlessButtonStyle"
    android:layout_width="170dp"
    android:layout_height="100dp"
    android:layout_weight="1"
    android:drawableLeft="@drawable/ic_action"
    android:gravity="center_horizontal|center_vertical"
    android:text="@string/block_apps"
    android:textSize="20sp"
        android:layout_alignTop="@+id/start_button"
        android:layout_alignParentRight="true"
        android:layout_alignParentEnd="true" />

    <Button
        android:id="@+id/start_button"
        style="?android:attr/borderlessButtonStyle"
        android:layout_width="170dp"
        android:layout_height="100dp"
        android:layout_gravity="right"
        android:layout_weight="1"
        android:drawableLeft="@drawable/ic_timer"
        android:gravity="center_horizontal|center_vertical"
        android:text="@string/start_apps"
        android:textSize="20sp"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true" />





    </RelativeLayout>

Upvotes: 1

Views: 300

Answers (2)

rajeev
rajeev

Reputation: 122

you just have to draw a line with width set to 1 and height to match_parent`

           <LinearLayout
            android:layout_marginTop="20sp"
            android:orientation="horizontal"

            android:background="@color/app_yellow"
            android:layout_width="match_parent"
            android:layout_height="match_parent">
            <Button
                android:gravity="center"

                android:layout_width="0sp"
                android:layout_weight="1"
                android:layout_height="wrap_content"
                android:text="Login"
                android:id="@+id/btnlogin"
                android:layout_gravity="center_vertical"
                android:background="@color/app_yellow"
                android:textColor="@color/white"
                android:onClick="Login"
                android:stateListAnimator="@null"
                />
            <View
                android:background="#ffffff"
                android:layout_marginTop="4sp"
                android:layout_marginBottom="4sp"
                android:layout_width="1sp"
                android:layout_height="match_parent"/>
            <Button
                android:layout_width="0sp"
                android:layout_weight="1"
                android:layout_height="wrap_content"
                android:text="Register"
                android:id="@+id/button7"
                android:background="@color/app_yellow"
                android:layout_gravity="center_vertical"
                android:textColor="@color/white"
                android:onClick="goDash"
                android:stateListAnimator="@null"
                 />

        </LinearLayout>`

Upvotes: 1

Veaceslav Gaidarji
Veaceslav Gaidarji

Reputation: 4311

Use FrameLayout as delimiter.

<LinearLayout
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:background="#dddddd"
        android:layout_marginBottom="5dp">
    </FrameLayout>

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

        <Button
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:text="New Button"
            android:id="@+id/button"
            android:layout_weight="1"/>

        <FrameLayout
            android:layout_width="1dp"
            android:layout_height="match_parent"
            android:background="#dddddd"
            android:layout_marginLeft="5dp"
            android:layout_marginRight="5dp">
        </FrameLayout>

        <Button
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:text="New Button"
            android:id="@+id/button2"
            android:layout_weight="1"
            />
    </LinearLayout>

</LinearLayout>

Upvotes: 0

Related Questions