Android NavigationView:不显示完整项目且不截断 [英] Android NavigationView : not show full item and not truncate

查看:231
本文介绍了Android NavigationView:不显示完整项目且不截断的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题:导航视图不显示菜单项的全文,也不截断文本.

我正确看到的这个项目-两个词"小标题":

This item I see correctly - two words "Small title":

<item
android:id="@+id/example1"
android:icon="@drawable/filter_2"
android:title="Small title"
android:checked="false"
app:actionLayout="@layout/menu_counter" />
/>

还有下一个项目-我只看到前两个单词"小标题",而没有截断下一个单词" andveryverylongword ":

And with next item - I see only first two words "Small title" without any truncate of next word "andveryverylongword":

<item
android:id="@+id/example2"
android:icon="@drawable/filter_2"
android:title="Small title andveryverylongword"
android:checked="false"
app:actionLayout="@layout/menu_counter" />
/>

小部件:

<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
ndroid:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="@layout/nav_header_main"
app:menu="@menu/activity_main_drawer"/>

也:AndroidStudio 1.5,支持库.

Also : AndroidStudio 1.5, support library.

这是Android Studio中的标准项目导航抽屉活动"的示例.

EDITED : Here is example of standart project "Navigation Drawer Activity" in Android Studio.

activity_main_drawer.xml:

activity_main_drawer.xml :

在手机中:

推荐答案

我刚刚开始工作了 *覆盖design_navigation_item.xml并将其更改为使用 android:layout_height="wrap_content" android:minHeight="?android:listPreferredItemHeightSmall"

I just got this working * Override design_navigation_item.xml and change it to use android:layout_height="wrap_content" android:minHeight="?android:listPreferredItemHeightSmall"

  • 覆盖design_navigation_menu_item.xml以使用maxLines = 2

Kinda很酷,我不敢相信这行得通.多亏了stackoverflow上的那个人,他讨论了覆盖图标大小的问题,这有助于我朝这个方向思考.

Kinda cool, I can't believe that works. Thanks to the guy on stackoverflow that talked about overriding icon size, which helped me thinking in this direction.

这篇关于Android NavigationView:不显示完整项目且不截断的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆