嗨,我需要添加阴影下我的标签布局(如在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"
添加到表格布局时,阴影被添加到底部和顶部。我需要的只是底部。如图所示...
我该怎么做呢?提前谢谢。
发布于 2017-04-15 11:01:36
实际上有一个非常简单的解决方案:只需将工具栏和TabLayout放在AppBarLayout中即可。例如:
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ToolbarTheme"
app:titleTextAppearance="@style/ThemeOverlay.AppCompat.ActionBar"
android:background="@color/colorPrimary"/>
<android.support.design.widget.TabLayout
android:id="@+id/tab_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorPrimary"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"/>
</android.support.design.widget.AppBarLayout>
这对我来说非常有效,也是将应用程序/工具栏和TabLayout结合在一起的常用方式。
发布于 2021-09-20 04:59:17
只需添加一行,它就可以工作了。
android:elevation="5dp"
查看完整代码:
<com.google.android.material.tabs.TabLayout
android:id="@+id/tabLayoutSave"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#fff"
android:elevation="5dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="parent"
app:tabIndicatorColor="#1d1d1f"
app:tabIndicatorHeight="4dp"
app:tabMode="fixed"
app:tabSelectedTextColor="#1d1d1f"
app:tabTextColor="#888888" />
发布于 2017-01-05 20:13:04
将标高添加到Tablayout
中。Material Design
android:elevation="15dp"
https://stackoverflow.com/questions/34675791
复制相似问题