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

3

我正在实现协调布局以支持可滚动的设计支持库,但无法看到具有正确高度的工具栏。我发布了我的布局文件。 我在片段中使用此布局,请指导我我的错误...我错在哪里。

<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>

你的问题详细是什么?你所说的“proper height”是什么意思? - natario
工具栏正在显示,但高度非常小。 - Ravi Yadav
你尝试在你的设备或模拟器上运行应用了吗? - A.R.
如果我给AppBarLayout设置高度,那么它就会显示,并且也可以滚动。 - Ravi Yadav
尝试过了,但问题仍然存在。 - Ravi Yadav
显示剩余2条评论
1个回答

0

工具栏只在运行时显示。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接