Android   发布时间:2022-04-28  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了Android导航视图 – 项目提升大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
有没有办法,使用Google支持库的NavigationView元素,在NavigationView内的项目上使用高程来实现如下所示:

您可以看到导航抽屉的标题一个高程,就像视图底部的页脚一样.

我试使用“android:elevation”属性,但似乎无法正常工作.
这是我目前的NavigationView代码

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://scheR_568_11845@as.android.com/apk/res/android"
    xmlns:app="http://scheR_568_11845@as.android.com/apk/res-auto"
    xmlns:tools="http://scheR_568_11845@as.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文件

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://scheR_568_11845@as.android.com/apk/res/android"
    xmlns:tools="http://scheR_568_11845@as.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>

如您所见,在这种情况下,高程不起作用.我怎么解决这个问题?

@H_403_27@解决方法
为header_marginBottom提供标题布局的根布局,以便可以获显示高程阴影的空间.

像这样:

机器人:layout_marginBottom = “8DP” 机器人:海拔= “4DP”

大佬总结

以上是大佬教程为你收集整理的Android导航视图 – 项目提升全部内容,希望文章能够帮你解决Android导航视图 – 项目提升所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。