2016-05-30 113 views
1

enter image description here如何刪除分隔在底部AppBarLayout

的我想刪除分隔線如上面的圖片。我嘗試過任何東西,但仍然沒有運氣。這是我迄今爲止嘗試過的。 styles.xml

<resources> 

<!-- Base application theme. --> 
<style name="AppTheme" parent="MaterialDrawerTheme.Light.DarkToolbar"> 
    <item name="android:windowContentOverlay">@null</item> 
    <item name="actionBarDivider">@null</item> 
    <item name="android:actionBarDivider">@null</item> 
</style> 

<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar"> 
<item name="android:windowContentOverlay">@null</item></style> 

<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" /> 

</resources> 

fragment.xml之

<?xml version="1.0" encoding="utf-8"?> 

<android.support.design.widget.CoordinatorLayout 
    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:theme="@style/AppTheme.AppBarOverlay" 
     android:fitsSystemWindows="true" 
     app:elevation="0dp"> 

     <android.support.design.widget.TabLayout 
      android:id="@+id/tab_layout" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      app:tabMode="fixed" 
      app:tabGravity="fill" 
      android:fillViewport="false" /> 
     <com.jaredrummler.materialspinner.MaterialSpinner 
      android:id="@+id/spinner" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:textColor="#000000" 
      /> 
    </android.support.design.widget.AppBarLayout> 

    <android.support.v4.view.ViewPager 
     android:id="@+id/view_pager" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior"/> 



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

</layout> 

是任何人有這個問題該如何解決?對不起,我的英語不好,並提前致謝!

+0

也許這是默認的高程。嘗試以編程方式將提升設置爲您的ActionBar爲0dp。 –

+0

你在哪裏添加了正在投射陰影的工具欄? –

+0

我的工具欄在主要活動 –

回答

0
+0

我讀過,但仍然讓我無處可去。你能指導我嗎? –

+0

@TommyWu看看第3個鏈接http://www.androidhive.info/2015/09/android-material-design-working-with-tabs/ – Elshan

0

見克里斯巴內斯cheesesquare樣本這個佈局:

<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:id="@+id/main_content" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <android.support.design.widget.AppBarLayout 
     android:id="@+id/appbar" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> 

     <android.support.v7.widget.Toolbar 
      android:id="@+id/toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="?attr/actionBarSize" 
      android:background="?attr/colorPrimary" 
      app:popupTheme="@style/ThemeOverlay.AppCompat.Light" 
      app:layout_scrollFlags="scroll|enterAlways|snap" /> 

     <android.support.design.widget.TabLayout 
      android:id="@+id/tabs" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" /> 

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

    <android.support.v4.view.ViewPager 
     android:id="@+id/viewpager" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior" /> 

    <android.support.design.widget.FloatingActionButton 
     android:id="@+id/fab" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="end|bottom" 
     android:layout_margin="@dimen/fab_margin" 
     android:src="@drawable/ic_done" /> 

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

最後,我想我的minSdkVersion提高15至21,並添加應用程序:海拔=「0dp」的代碼。它工作完美。感謝球員的反饋!

+0

謝謝you.it工作正常 – Steve

0

它不是分隔線,而是海拔Toolbar。你應該把它設置爲AppBarLayout,最高海拔和Toolbar

int elevationAppBar = ViewCompat.getElevation(mAppBarLayout); 
int elevationToolbar = getSupportActionbar().getElevation(); 
elevationToolbar = Math.max(elevationToolbar, elevationAppBar); 
getSupportActionBar().setElevation(elevationToolbar); 
1

你必須設置高度=「0dp」,如: <android.support.design.widget.AppBarLayout android:layout_height="wrap_content" android:layout_width="match_parent" app:elevation="0dp" android:theme="@style/AppTheme.AppBarOverlay"> </android.support.design.widget.AppBarLayout>

但似乎這個高度是從父活動不你的片段。因此,請確保您的活動你toolbar_layout擴展和活動的AppBarLayout的內部工具欄設置應用程序:海拔=「0dp將解決您的問題

或者

同時檢查水庫>值 - >風格。 XML和樣式v21.xml文件設置: <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> <item name="android:windowContentOverlay">@null</item> </style>

或者

如果你不使用的工具欄,你必須(0)在你的動作條叫setElevation請注意,如果您使用的支持。圖書館,你必須這樣稱呼它:

getSupportActionBar().setElevation(0); 

這是由windowContentOverlay樣式項不受影響,所以款式不需要更改

0

應設置應用程序:layout_insetEdge =「none」和應用程序:海拔AppBarLayout.I =「0dp」希望沒關係。

<android.support.design.widget.AppBarLayout 
    android:id="@+id/appBar" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    app:elevation="0dp" 
    app:layout_insetEdge="none" 
     > 
.... 
</android.support.design.widget.AppBarLayout>