Android 将阴影添加到底部选项卡

Android 将阴影添加到底部选项卡,android,android-layout,Android,Android Layout,这是我创建选项卡(底部)的代码,工作正常 <?xml version="1.0" encoding="utf-8"?> <TabHost xmlns:android="http://schemas.android.com/apk/res/android" android:id="@android:id/tabhost" android:layout_width="fill_parent" android:layout_height="fill_parent"> <

这是我创建选项卡(底部)的代码,工作正常

<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent">

<RelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <TabWidget
        android:id="@android:id/tabs"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true" />

    <FrameLayout
        android:id="@android:id/tabcontent"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:padding="5dp">

        <LinearLayout
            android:id="@+id/tab1"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:elevation="10dp"
            android:orientation="vertical">

            <!-- Tab 1 content -->
            <include layout="@layout/tab1" />

        </LinearLayout>

        <LinearLayout
            android:id="@+id/tab2"
            android:layout_width="match_parent"
            android:layout_height="450dp"
            android:orientation="vertical">


            <!-- Tab 2 content -->
            <include layout="@layout/tab2" />

        </LinearLayout>

    </FrameLayout>

</RelativeLayout>

</TabHost>


我以多种方式(向选项卡、tabHost和布局…)添加了立面属性,但没有一种方法有效。我在这里找到了一些解决方案,但没有一个适合我。对这段代码有什么想法吗?

立面属性仅适用于具有背景的视图,但您的视图是透明的。您可以尝试为TabHost设置背景和标高,或将整个选项卡栏放入AppBarLayout。

谢谢!我已经将选项卡的布局包装成一个带有背景和立面的线性布局,效果很好。