我有一个类似以下的布局:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_height="wrap_content"
android:elevation="4dp"
android:background="?attr/colorPrimary"
android:layout_width="match_parent"
android:minHeight="?attr/actionBarSize"/>
<FrameLayout
android:id="@+id/content"
android:layout_below="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</RelativeLayout>
这是我活动的基本布局文件,然后我用各种片段替换FrameLayout。其中一个这样的片段具有以下布局:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<SlidingTabLayout
android:id="@+id/sliding_tabs"
android:layout_width="match_parent"
android:elevation="4dp"
android:layout_height="wrap_content"/>
<android.support.v4.view.ViewPager
android:id="@+id/profileViewPager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/sliding_tabs"
android:background="@android:color/white"/>
<FloatingActionButton
android:id="@+id/floatingButton"
android:layout_width="72dp"
android:layout_height="72dp"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_marginRight="16dp"
android:layout_marginBottom="16dp"/>
</RelativeLayout>
我希望设置工具栏和滑动选项卡的高度都为4dp,这样工具栏不会对选项卡产生阴影,但实际上它确实有阴影。我不想在代码中设置工具栏的高度 - 有没有办法防止工具栏产生阴影?我原以为由于两个视图都处于4dp高度,即使它们不在同一个布局中,也不会产生阴影。感谢您的帮助。