android - 为什么工具栏没有显示在我的布局中

标签 android android-fragments toolbar androiddesignsupport

我正在使用协调器布局来实现可滚动的设计支持库,但无法看到具有适当高度的工具栏。我正在发布我的布局文件。 我正在 fragment 中使用此布局并指导我了解我的错误......我哪里出错了。

<android.support.design.widget.CoordinatorLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:myfont="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">


    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        >
        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar_home"
            style="@style/Widget.MyApp.ActionBar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:minHeight="?attr/actionBarSize"
            app:layout_scrollFlags="scroll|enterAlways"
            android:fitsSystemWindows="false"
            app:layout_collapseMode="pin"/>
    </android.support.design.widget.AppBarLayout>
    <android.support.v4.widget.NestedScrollView
        android:id="@+id/scrollviewHome"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginBottom="10dp"
        android:layout_marginTop="-5dp"
       >
<!-- app:layout_behavior="@string/appbar_scrolling_view_behavior"-->
        <RelativeLayout
            android:id="@+id/mainLayout"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@color/White">

            <RelativeLayout
                android:id="@+id/top"
                android:layout_width="match_parent"
                android:layout_height="180dp">

                <android.support.v4.view.ViewPager
                    android:id="@+id/viewpager"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_marginLeft="10dp"
                    android:layout_marginRight="10dp"
                    android:layout_marginTop="15dp" />

                <com.viewpagerindicator.CirclePageIndicator
                    android:id="@+id/titles"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_alignParentBottom="true"
                    android:layout_marginBottom="10dp"
                    android:layout_marginLeft="10dp"
                    android:layout_marginRight="10dp" />
            </RelativeLayout>

            <RelativeLayout
                android:id="@+id/lable_Category_Layout"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/top">

                <com.itw.b2b.rapidcommv2.util.TextViewPlus
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:background="@color/White"
                    android:gravity="left"
                    android:paddingLeft="5dp"
                    android:text="Our Products"
                    android:textColor="@color/Black"
                    android:textSize="20sp"
                    android:textStyle="bold"
                    myfont:customFont="@string/Roboto_Light" />
            </RelativeLayout>

            <RelativeLayout
                android:id="@+id/middle_layout"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_below="@+id/lable_Category_Layout">

                <GridView
                    android:id="@+id/custom_grid_home"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_alignParentBottom="true"
                    android:layout_marginLeft="5dp"
                    android:background="@color/White"
                    android:columnWidth="160dp"
                    android:horizontalSpacing="5dp"
                    android:isScrollContainer="false"
                    android:numColumns="2"
                    android:padding="5dp"
                    android:paddingBottom="10dp"
                    android:scrollbars="none"
                    android:verticalSpacing="10dp" />


            </RelativeLayout>

        </RelativeLayout>

    </android.support.v4.widget.NestedScrollView>


    <!-- For internet connection-->
    <RelativeLayout
        android:id="@+id/RelativeNoInterNetConnection"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="center"
        android:visibility="gone">

        <ImageView
            android:id="@+id/imageView1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:src="@drawable/wifi" />

        <com.itw.b2b.rapidcommv2.util.TextViewPlus
            android:id="@+id/textViewErrorMessage"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignLeft="@+id/imageView1"
            android:layout_below="@+id/imageView1"
            android:gravity="center"
            android:text="@string/nointernetconnectionDescription"
            android:textSize="15sp"
            myfont:customFont="@string/Roboto_Light" />

        <Button
            android:id="@+id/button_referesh"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/textViewErrorMessage"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="14dp"
            android:text="Refresh" />
    </RelativeLayout>
    <ProgressBar
        android:id="@+id/progressBarInternetConnection"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"

        />
    <com.wangjie.rapidfloatingactionbutton.RapidFloatingActionLayout
        xmlns:rfal="http://schemas.android.com/apk/res-auto"
        android:id="@+id/activity_main_rfal"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        rfal:rfal_frame_alpha="0.7"
        rfal:rfal_frame_color="#80000000"
        android:layout_alignParentBottom="true"
        >

        <com.wangjie.rapidfloatingactionbutton.RapidFloatingActionButton
            xmlns:rfab="http://schemas.android.com/apk/res-auto"
            android:id="@+id/activity_main_rfab"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_alignParentRight="true"
            android:layout_marginBottom="15dp"
            android:layout_marginRight="15dp"
            android:padding="8dp"
            rfab:rfab_color_normal="@color/list_background"
            rfab:rfab_color_pressed="@color/list_background_pressed"
            rfab:rfab_drawable="@drawable/rfab__drawable_rfab_default"
            rfab:rfab_shadow_color="#999999"
            rfab:rfab_shadow_dx="0dp"
            rfab:rfab_shadow_dy="5dp"
            rfab:rfab_shadow_radius="7dp"
            rfab:rfab_size="normal"
           />
    </com.wangjie.rapidfloatingactionbutton.RapidFloatingActionLayout>

</android.support.design.widget.CoordinatorLayout>

最佳答案

工具栏仅显示运行时。

关于android - 为什么工具栏没有显示在我的布局中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31113204/

相关文章:

javascript - 如何锁定任何浏览器的屏幕宽度?

带有 ListView 的 Android Material Signature 元素

editor - 动态更改 Quill 工具栏可见性

java - 动态更改 RecyclerView 单击中的工具栏项目可见性(无需 LongClick)

android - 使用 Parse Twitter/Facebook 身份验证注销或切换帐户

android - MPAndroidChart 有没有办法为不同的条设置不同的颜色?

android - 如何在android中将图像添加到具有多个页面的pdf中

android - 如何实现多窗口布局(如默认浏览器)(打开多个文件的编辑器)

android - 在 fragment 中动态添加 TextView

androidx.navigation 库更新到 2.2.2 版本发布构建问题