2016-03-19 37 views
2

如何在NavigationView中更改标题视图高度?我旁边的xml: activity_main.xml中如何在NavigationView中更改标题高度?

<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忽略所有维度属性,并显示了默认大小头。如何解决它?

回答

3

您需要更改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"/> 
+0

如何使用WRAP_CONTENT为'ImageView'。它不适用于'NavigationView'。我的ImageView'填充最大父母高度都一样。 –

+0

对不起,但我不明白你想达到什么。可以编辑你的问题,并澄清什么是预期的结果,也许与图像? –

相关问题