如何更改 NavigationView
中的标题 View 高度?我有下一个 xml:
activity_main.xml
<android.support.v4.widget.DrawerLayout
android:id="@+id/dlDrawerContainer"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context=".activity.MainActivity"
xmlns:app="http://schemas.android.com/apk/res-auto">
<!-- Some data -->
<!-- Drawer -->
<android.support.design.widget.NavigationView
android:fitsSystemWindows="true"
android:id="@+id/nvNavigation"
android:layout_width="wrap_content"
android:maxWidth="400dp"
android:layout_height="match_parent"
android:layout_gravity="start"
app:headerLayout="@layout/navigation_header"/>
</android.support.v4.widget.DrawerLayout>
navigation_header.xml
<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/ic_header"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:maxWidth="400dp"
android:maxHeight="100dp"
android:scaleType="matrix"/>
但是 NavigationView
会忽略所有维度属性并显示具有默认大小的标题。如何解决?
最佳答案
您需要更改 navigation_header.xml 中的 layout_height
值。
例如,这会将页眉高度更改为 100dp:
<?xml version="1.0" encoding="utf-8"?>
<ImageView
xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/ic_header"
android:layout_width="match_parent"
android:layout_height="100dp"
android:maxWidth="400dp"
android:maxHeight="100dp"
android:scaleType="matrix"/>
关于android - 如何更改 NavigationView 中的标题高度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36105272/