如何在Android中的标签布局或工具栏上添加底影 [英] How to add bottom shadow to tab layout or Toolbar in android
本文介绍了如何在Android中的标签布局或工具栏上添加底影的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要在我的标签页布局下添加阴影(例如在Skype中)。
Hi i need add shadow under my tab layout (like in skype).
我的活动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,阴影被添加到底部和顶部..我只需要底部。查看图片...
When i add android:elevation="10dp"
to Tablayout, shadow was added bottom and top .. I need just bottom. See image...
我该怎么办这个 ?
预先感谢。
How can i do this ? Thanks in advance.
推荐答案
只需将海拔高度添加到 Tablayout
(0dp-25dp)。阅读材料设计指南以获取有关高程的更多信息。
Just add elevation to your Tablayout
(0dp - 25dp). Read the material design guidelines for more information about elevation.
android:elevation="10dp"
编辑:
将其添加到您的布局和工具栏中
add it to both your tablayout and toolbar
<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中的标签布局或工具栏上添加底影的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文