有没有办法,使用Google支持库的NavigationView元素,在NavigationView内的项目上使用高程来实现如下所示:
您可以看到导航抽屉的标题有一个高程,就像视图底部的页脚一样.
我试图使用“android:elevation”属性,但似乎无法正常工作.
这是我目前的NavigationView代码:
<?xml version="1.0" encoding="utf-8"?> <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/drawer_layout" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true" tools:openDrawer="end"> <include layout="@layout/app_bar_product_list" android:layout_width="match_parent" android:layout_height="match_parent" /> <android.support.design.widget.NavigationView android:id="@+id/nav_view" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_gravity="end" android:fitsSystemWindows="true" app:headerLayout="@layout/nav_header_filters"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="bottom" android:gravity="center|end" android:padding="16dp" android:elevation="16dp" android:orientation="horizontal" tools:targetApi="lollipop"> <TextView android:textAppearance="@style/TextAppearance.AppCompat.Button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Clear"/> </LinearLayout> </android.support.design.widget.NavigationView> </android.support.v4.widget.DrawerLayout>
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@color/colorAccent" android:elevation="8dp" android:gravity="bottom" android:orientation="vertical" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" android:theme="@style/ThemeOverlay.AppCompat.Light" tools:targetApi="lollipop"> <android.support.v4.widget.Space android:layout_width="match_parent" android:layout_height="@dimen/status_cheat" /> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center" android:orientation="horizontal"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/ordina_per" android:textAppearance="@style/TextAppearance.AppCompat.Subhead" android:textColor="@android:color/white" /> <android.support.v7.widget.AppCompatSpinner android:id="@+id/spinner_orders" style="@style/SpinnerStyle" android:layout_width="match_parent" android:layout_height="wrap_content" /> </LinearLayout> </LinearLayout>