您好,我需要在我的选项卡布局下添加阴影(就像在 Skype 中一样)。
我的 Activity xml:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.Toolbar xmlns:local="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
android:background="@color/splashGreenTop"
local:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
local:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
<android.support.design.widget.TabLayout
android:id="@+id/tab_layout"
android:layout_below="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:elevation="0dp"
android:minHeight="?attr/actionBarSize" />
<FrameLayout
android:layout_width="match_parent"
android:layout_below="@+id/tab_layout"
android:id="@+id/tabContainer"
android:layout_height="match_parent" />
</RelativeLayout>
当我将 android:elevation="10dp"
添加到 Tablayout 时,阴影被添加到底部和顶部。我只需要底部。看图...
我该怎么做? 提前致谢。
最佳答案
只需将高度添加到您的 Tablayout
(0dp - 25dp)。阅读 material design有关海拔的更多信息的指南。
android:elevation="10dp"
编辑:
将它添加到您的 tablayout 和工具栏
<android.support.v7.widget.Toolbar xmlns:local="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
android:background="@color/splashGreenTop"
local:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
local:popupTheme="@style/ThemeOverlay.AppCompat.Light"
android:elevation="10dp" />
<android.support.design.widget.TabLayout
android:id="@+id/tab_layout"
android:layout_below="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:minHeight="?attr/actionBarSize"
android:elevation="10dp"/>
关于android - 如何在android中将底部阴影添加到选项卡布局或工具栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34675791/