【问题标题】:Elevation has no shadow海拔没有阴影
【发布时间】:2018-08-21 08:30:17
【问题描述】:

我的标签下面不会显示任何阴影,我的代码有什么问题:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#171717"
    android:orientation="vertical">

    <android.support.design.widget.TabLayout
        android:id="@+id/tabLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:minHeight="?actionBarSize"
        android:elevation="10dp"
        app:tabBackground="@color/tabBackground"
        app:tabGravity="fill"
        app:tabIndicatorColor="#425ced"
        app:tabIndicatorHeight="4dp"
        app:tabMode="fixed"
        app:tabSelectedTextColor="#425ced"
        app:tabTextColor="#e5e5e5"
        >
    </android.support.design.widget.TabLayout>

    <android.support.v4.view.ViewPager
        android:id="@+id/viewPager"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:elevation="0dp"/>
</LinearLayout>

【问题讨论】:

  • 您使用的是哪个版本的支持库? 27.0.0刚刚解决了大部分的提升问题,老版本不支持所有组件的提升
  • [在此处查看您的答案](stackoverflow.com/a/43407492/7707187) 它对我有用

标签: android android-layout android-tablayout


【解决方案1】:

使用

app:elevation="10dp"

代替

android:elevation="10dp"

试试这个

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#171717"
    android:orientation="vertical">

    <android.support.design.widget.TabLayout
        android:id="@+id/tabLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:minHeight="?actionBarSize"
        app:elevation="10dp"
        app:tabBackground="@color/tabBackground"
        app:tabGravity="fill"
        app:tabIndicatorColor="#425ced"
        app:tabIndicatorHeight="4dp"
        app:tabMode="fixed"
        app:tabSelectedTextColor="#425ced"
        app:tabTextColor="#e5e5e5"
        >
    </android.support.design.widget.TabLayout>

    <android.support.v4.view.ViewPager
        android:id="@+id/viewPager"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:elevation="0dp"/>
</LinearLayout>

【讨论】:

    【解决方案2】:

    你不应该使用

    android:elevation="10dp"
    

    用这个

    app:elevation="10dp"
    

    并将您的支持库升级到最新版本以获得更好的性能。祝你好运

    【讨论】:

      猜你喜欢
      • 2015-02-14
      • 2016-11-11
      • 2015-08-22
      • 2015-02-13
      • 2016-02-03
      • 2017-10-15
      • 2018-07-09
      • 1970-01-01
      • 2017-07-13
      相关资源
      最近更新 更多