Search code examples
androiddesign-patternsandroid-actionbarcustom-action

Set a custom action bar..


I want to set a custom action bar i provide a image below.. this action bar i want to implement in android app and it should be completely customized ..How to set it to fragment or should i set using an activity ..i am little bit confused so please suggest me proper answer so i can do it properly..

enter image description here

Please Suggest me the answers so i can implement it in my app..


Solution

  •    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        app:elevation="0dp"
        android:background="@drawable/custum_background_toolbar"
        android:layout_height="wrap_content">
    <android.support.v7.widget.Toolbar
        android:layout_width="match_parent"
        android:layout_height="@dimen/action_bar_height"
        android:layout_gravity="top"
        android:layout_marginLeft="@dimen/button_margin"
        android:layout_marginRight="@dimen/button_margin"
        android:layout_marginBottom="@dimen/button_margin"
        android:background="@drawable/custum_button_red_background"
        app:titleTextColor="@color/white">
    
        <RelativeLayout
            android:layout_width="match_parent"
            android:gravity="center_vertical"
            android:layout_height="match_parent">
        <ImageView
            android:layout_width="wrap_content"
            android:layout_gravity="start"
            android:id="@+id/leftArrowContacts"
            android:layout_alignParentStart="true"
            android:layout_height="wrap_content"
            app:srcCompat="@drawable/ic_keyboard_backspace_white_24dp"
            android:layout_alignParentLeft="true" />
        <TextView
            android:layout_width="wrap_content"
            android:text="@string/anouncer_list"
            android:layout_marginLeft="@dimen/_25sdp"
            android:layout_alignParentStart="true"
            android:textColor="@color/white"
            android:textSize="@dimen/_14sdp"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true" />
            <ImageView
                android:id="@+id/add_contacts"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentRight="true"
                android:layout_marginRight="@dimen/_10sdp"
                app:srcCompat="@drawable/ic_add_white_24dp"/>
        </RelativeLayout>
    </android.support.v7.widget.Toolbar>
    </android.support.design.widget.AppBarLayout>