代码之家  ›  专栏  ›  技术社区  ›  Faizan Haidar Khan

导航抽屉中的表格布局与收费栏重叠

  •  -2
  • Faizan Haidar Khan  · 技术社区  · 6 年前

    我使用了导航抽屉活动并实现了 TabLayout 但是当应用程序运行时,工具栏不可见,只有tablayout代替了工具栏。但在预览窗格工具栏是可见的,这发生在我运行这个应用程序的设备上。请帮帮我

    这是 app_bar_main.xml

    <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">
    
    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/AppTheme.AppBarOverlay">
    
        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="@color/colorToolbar"
            app:popupTheme="@style/AppTheme.PopupOverlay"
            app:contentInsetLeft="0dp"
            app:contentInsetStart="0dp"
            app:contentInsetStartWithNavigation="0dp"
            >
    
            <ImageView
                android:layout_width="@dimen/_40sdp"
                android:layout_height="match_parent"
                android:src="@drawable/logo_shopline"
                />
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:text="ShopLine"
                android:gravity="center"
                android:textSize="@dimen/_18sdp"
                android:textColor="@color/colorShopLineText"
                android:paddingLeft="@dimen/_2sdp"
                />
    
        </android.support.v7.widget.Toolbar>
    
    
    </android.support.design.widget.AppBarLayout>
    
    <include layout="@layout/content_main" />
    

    content_main.xml

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    tools:context=".MainActivity"
    tools:showIn="@layout/app_bar_main">
    
    <android.support.design.widget.AppBarLayout
        android:id="@+id/appBarLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
    
        <android.support.design.widget.TabLayout
            android:id="@+id/tabs"
            android:layout_width="match_parent"
            android:layout_height="@dimen/custom_tab_layout_height"
            app:tabMode="fixed"
            app:tabGravity="fill"
            />
    </android.support.design.widget.AppBarLayout>
    
    <android.support.v4.view.ViewPager
        android:id="@+id/viewpager"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_below="@id/appBarLayout"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"  />
    

    Here is the screen shot

    2 回复  |  直到 6 年前
        1
  •  0
  •   ʍѳђઽ૯ท    6 年前

    实际上是因为两个原因 AppBarLayout 你有哪些android可能无法识别你所写的布局。

    简单地说,去掉另一个 你的布局是这样的:

    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/AppTheme.AppBarOverlay">
    
        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="@color/colorToolbar"
            app:popupTheme="@style/AppTheme.PopupOverlay"
            app:contentInsetLeft="0dp"
            app:contentInsetStart="0dp"
            app:contentInsetStartWithNavigation="0dp">
    
            <ImageView
                android:layout_width="@dimen/_40sdp"
                android:layout_height="match_parent"
                android:src="@drawable/logo_shopline" />  
    
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:text="ShopLine"
                android:gravity="center"
                android:textSize="@dimen/_18sdp"
                android:textColor="@color/colorShopLineText"
                android:paddingLeft="@dimen/_2sdp" />
    
        </android.support.v7.widget.Toolbar>
    
     <android.support.design.widget.TabLayout
            android:id="@+id/tabs"
            android:layout_width="match_parent"
            android:layout_height="@dimen/custom_tab_layout_height"
            android:layout_gravity="bottom"
            app:tabMode="fixed"
            app:tabGravity="fill" />
    
    </android.support.design.widget.AppBarLayout>
    
        2
  •  0
  •   Kuldeep Jindani    6 年前

    请把这条线改一下

     <android.support.v4.view.ViewPager
         android:id="@+id/viewpager"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
    

    安卓:布局如下=“@+id/appBarLayout”

      app:layout_behavior="@string/appbar_scrolling_view_behavior"  />