There's an unnecessary top padding between the header and the first item shown in this picture.
How it can be removed?
you can find the source code here: https://github.com/chrisbanes/cheesesquare
There's an unnecessary top padding between the header and the first item shown in this picture.
How it can be removed?
you can find the source code here: https://github.com/chrisbanes/cheesesquare
您可以在您的dimens.xml
as 处覆盖预定义的尺寸;
<dimen name="design_navigation_padding_top_default" tools:override="true">0dp</dimen>
<dimen name="design_navigation_separator_vertical_padding" tools:override="true">0dp</dimen>
<dimen name="design_navigation_padding_bottom" tools:override="true">0dp</dimen>
其他可能的值在这里:https ://github.com/android/platform_frameworks_support/blob/master/design/res/values/dimens.xml
你应该阅读伊恩的回答。NavigationView 遵循 Material 指南,您不应违反这些规范。
但是,目前,您可以在项目中覆盖此值。
只需添加到您的dimens.xml
:
<dimen name="design_navigation_separator_vertical_padding">0dp</dimen>
警告:
使用NavigationView
作为LinearLayout
标题视图。您可以在源代码中看到此布局:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="@dimen/design_navigation_separator_vertical_padding" />
NavigationView
寻求匹配导航抽屉的材料设计规范,该规范声明内容区域之间的空间为 8dp。通常,没有办法覆盖NavigationView
以专门破坏规范。
非常简单的步骤:将以下属性添加到您的基本应用程序主题 (stylename=AppTheme) Style.xml :
<item name="listPreferredItemHeightSmall">18dp</item>
在这里回答了加布里埃尔的回答
只需添加到您的dimens.xml:
<dimen name="design_navigation_separator_vertical_padding">0dp</dimen>