2015-07-19 710 views
4

我想要刪除TabLayout下面的陰影。我試着設置此功能爲題材,但它不工作:在Android的TabLayout上設置陰影

<item name="android:windowContentOverlay">@null<item/> 

或者

<item name="windowContentOverlay">@null<item/> 

我是遊蕩,如果有另一種方式做到這一點,從XML聲明或從後面的代碼在TabLayout實例上。

我知道這個解決方案,它不適合我。 Getting rid of the gradient at the top of an Activity (Android) 請,不建議主題修復,我知道這是最好的android方式去這裏,但它不是我的選擇。

這是我的XML聲明:

<android.support.design.widget.TabLayout xmlns:app="http://schemas.android.com/apk/res-auto" 
       android:id="@+id/sliding_tabs" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_gravity="center_horizontal" 
       android:layout_marginLeft="10dp" 
       android:layout_marginRight="10dp" 
       android:background="@android:color/white" 
       app:backgroundTint="@android:color/transparent" 
       app:tabIndicatorColor="@android:color/transparent" 
       app:tabMode="scrollable" 
       app:tabSelectedTextColor="@color/tab_on_state" 
       app:tabTextColor="@color/tab_off_state" /> 

回答

3

影不由TabLayout但在它所在的容器中投。 如果您在ActionBar中使用TabLayout,則將ActionBar的背景設置爲純色以移除陰影。 我已經嘗試過它在ActionBar,但我想它應該適用於其他模式,如AppBarLayout

+0

嗨,我沒有使用一個操作欄,它在一個佈局。 – Dus

+0

這是網絡上很多類似答案中唯一正確的答案。看起來容器正在造成陰影而不是TabLayout。我只是在TabLayout容器中將android:elevation設置爲0。 –