Remove the shadow below TabLayout on android

試著忘記壹切 提交于 2019-12-21 07:54:23

问题


I'm trying to remove the shadow below tabs while using TabLayout, which is defined in a normal layout (and not as a part of a toolbar or actionbar).

Setting theme as

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

or

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

didn't work.

Also, setting elevation to 0 didn't help either.

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

回答1:


I'm assuming your TabLayout is inside AppBarLayout, that shadow comes with AppBarLayout, add this app:elevation="0dp" to that widget and I believe you're good to go.




回答2:


I try app:elevation="0dp" work and android:elevation="0dp" does not work in AppBarLayout




回答3:


I had to set the elevation to 0dp and I also change the theme of AppBarLayout to @style/Base.Widget.Design.TabLayout and it worked for me




回答4:


Put getSupportActionBar().setElevation(0); in MainActivity java file like this:

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    getSupportActionBar().setElevation(0);


来源:https://stackoverflow.com/questions/31543309/remove-the-shadow-below-tablayout-on-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!