Sha*_*ana 5 android navigation-drawer
如何添加页脚NavigationView?在我的情况下,NavigationView项目由菜单资源膨胀.最初我尝试将LinearLayout添加为页脚,但是NavigationView不可滚动且页脚与导航菜单项重叠.我想将Google Play评分细分作为页脚实现,如下图所示:
navigation_drawer.xml:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorPrimary"
android:id="@+id/toolbar"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:title="@string/app_name" />
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:id="@+id/drawerLayout">
<FrameLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/containerView">
</FrameLayout>
<android.support.design.widget.NavigationView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:id="@+id/shitstuff"
app:itemTextColor="@color/green"
app:menu="@menu/drawermenu"
app:headerLayout="@layout/drawer_header"
android:layout_marginTop="-24dp">
</android.support.design.widget.NavigationView>
</android.support.v4.widget.DrawerLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
这很简单:
只需在NavigationView中包含所需的页脚.你可以用我的例子 - 像魅力一样!
<android.support.design.widget.NavigationView
android:id="@+id/nvView"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="@android:color/white"
app:headerLayout="@layout/navigation_header"
app:itemTextColor="@android:color/black"
app:menu="@menu/drawer_view">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:clickable="true"
android:orientation="vertical">
<TextView
android:id="@+id/nav_footer_textview"
android:layout_width="match_parent"
android:layout_height="48dp"
android:gravity="center"
android:text="Your Footer Text Here" />
</LinearLayout>
</android.support.design.widget.NavigationView>
Run Code Online (Sandbox Code Playgroud)
您可以使用任何(或多或少复杂)布局.(Afaik这个页脚不会滚动并将被修复).
| 归档时间: |
|
| 查看次数: |
7363 次 |
| 最近记录: |