I am using custom toolbar. but it is not showing proper result as required. in my design view it shows fine. but when i run the app search bar which i added is not showing. follow the screen shots for more details.
This is my required out put. and in my design view it shows same.
header_home.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize"
android:id="@+id/header_home1"
android:gravity="center_vertical"
android:orientation="vertical">
<ImageView
android:id="@+id/header_home_iv_header_bg"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorPrimaryDark"
android:contentDescription="@null" />
<LinearLayout
android:id="@+id/header_home_ll_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="@dimen/dimen_10"
android:layout_marginTop="@dimen/dimen_10"
android:gravity="center_vertical">
<ImageButton
android:id="@+id/header_ib_menu"
style="@style/ibHeader"
android:contentDescription="@null"
android:minWidth="@dimen/dimen_50"
android:src="@drawable/ic_menu" />
<!--android:background="@drawable/bg_search_header"-->
<ImageButton
android:id="@+id/header_ib_my_cart"
style="@style/ibHeader"
android:layout_marginStart="@dimen/dimen_5"
android:contentDescription="@null"
android:src="@drawable/ic_cart_white" />
<ImageButton
android:id="@+id/header_ib_notification"
style="@style/ibHeader"
android:contentDescription="@null"
android:src="@drawable/ic_notification_white" />
</LinearLayout>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize"
android:gravity="center_vertical"
android:layout_below="@+id/header_home1"
android:orientation="vertical">
<ImageView
android:id="@+id/header_home_iv_header_bg2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorPrimaryDark"
android:contentDescription="@null" />
<LinearLayout
android:id="@+id/header_home_ll_search"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dp"
android:background="@drawable/bg_search_header"
android:gravity="center_vertical"
android:orientation="horizontal">
<ImageButton
android:id="@+id/header_ib_search"
style="@style/ibHeader"
android:clickable="false"
android:contentDescription="@null"
android:padding="@dimen/dimen_10"
android:src="@drawable/ic_search_white" />
<com.lessohome.customview.CustomFontTextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:shadowColor="@color/colorFontDarkGray"
android:shadowDx="1"
android:shadowDy="1"
android:shadowRadius="2"
android:text="@string/search_for_products"
android:textColor="@color/colorWhite"
android:textSize="@dimen/font_14"
app:fontText="@string/Muli_Bold" />
<!--android:shadowColor="@color/colorFontDarkGray"
android:shadowDx="1"
android:shadowDy="1"
android:shadowRadius="2"-->
<ImageButton
android:id="@+id/header_ib_qr_code_scan"
style="@style/ibHeader"
android:contentDescription="@null"
android:padding="@dimen/dimen_10"
android:src="@drawable/ic_scan_white" />
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
When i run the app, it shows only this much part of toolbar. even in my fragment_home.xml ,in design view it shows same. search bar is not showing.
fragment_home.xml
<android.support.v7.widget.Toolbar
android:id="@+id/fragment_home_tb_toolbar"
style="@style/toolbarStyle"
android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize"
android:elevation="@dimen/dimen_4"
android:fitsSystemWindows="false">
<include
android:id="@+id/fragment_home_header"
layout="@layout/header_home"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</android.support.v7.widget.Toolbar>
Can any one help me to solve this issue, I am not able to find what is wrong am i doing.
Height of toolbar and other relative layouts are same i.e. android:layout_height="?android:attr/actionBarSize"
That's why there is only Header layout is visible not the search layout because header layout occupying the whole height of the toolbar and search layout is below the header layout. Change the height of toolbar and you will get the desired result.