android - Navigation View Multiline Text -


i have app navigation view drawerlayout. add programmatically items in menu because receive information on network. sometimes, item name can long , cut off having ellipsize icon "..."

does have idea on how have multiline menu items?

thanks

override design_navigation_menu_item.xml android support design library , modify things need (set android:ellipsize="end" , android:maxlines="2")

your res/layout/design_navigation_menu_item.xml should this:

<?xml version="1.0" encoding="utf-8"?> <merge xmlns:android="http://schemas.android.com/apk/res/android">     <checkedtextview         android:id="@+id/design_menu_item_text"         android:layout_width="0dp"         android:layout_height="match_parent"         android:layout_weight="1"         android:drawablepadding="@dimen/design_navigation_icon_padding"         android:gravity="center_vertical|start"         android:textappearance="@style/textappearance.appcompat.body2"         android:ellipsize="end"         android:maxlines="2" />     <viewstub         android:id="@+id/design_menu_item_action_area_stub"         android:inflatedid="@+id/design_menu_item_action_area"         android:layout="@layout/design_menu_item_action_area"         android:layout_width="wrap_content"         android:layout_height="match_parent" /> </merge> 

however, should ellipsize text follow material design guidelines.

you have not override ellipsize text:

  • add new style styles.xml
  • set new style navigationview

res / values / styles.xml

<style name="textappearance">     <item name="android:ellipsize">end</item> </style> 

res / layout / activity_main.xml

<android.support.design.widget.navigationview     android:id="@+id/nav_view"     android: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"     app:theme="@style/textappearance" /> 

Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -