【问题标题】:Setting the shadow on android's TabLayout在android的TabLayout上设置阴影
【发布时间】:2017-07-13 23:28:44
【问题描述】:

我想去掉 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" />

【问题讨论】:

    标签: android android-xml android-tablayout


    【解决方案1】:

    Shadow 不是由 TabLayout 投射,而是由它所在的容器投射。 如果您在 ActionBar 中使用 TabLayout,则将 ActionBar 的背景设置为纯色以去除阴影。 我已经在 ActionBar 上尝试过,但我想它应该适用于 AppBarLayout 等其他模式

    【讨论】:

    • 嗨,我没有使用操作栏,它在其中一种布局中。
    • 这是网络上众多类似答案中唯一正确的答案。似乎是容器导致了阴影,而不是 TabLayout。我只是在 TabLayout 容器中将 android:elevation 设置为 0。
    猜你喜欢
    • 2015-10-11
    • 1970-01-01
    • 2016-09-24
    • 2011-09-18
    • 1970-01-01
    • 2017-08-23
    • 1970-01-01
    • 2011-05-23
    • 2017-05-10
    相关资源
    最近更新 更多