【发布时间】:2018-06-24 17:00:51
【问题描述】:
我正在使用自定义工具栏。但它没有按要求显示正确的结果。在我的设计视图中,它显示得很好。但是当我运行我添加的应用程序搜索栏时没有显示。按照屏幕截图了解更多详情。
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>
当我运行应用程序时,它只显示工具栏的这么多部分。即使在我的 fragment_home.xml 中,在设计视图中也显示相同。搜索栏未显示。
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>
谁能帮我解决这个问题,我无法找到我做错了什么。
【问题讨论】:
标签: android android-layout android-fragments android-actionbar android-toolbar