only ListView scrolls are displayed, while ImageView remains
It looks like your box contains an ImageView at the top, followed by a ListView . In this configuration, only the ListView will scroll (because this is the only view that scrolls).
You need to add ImageView as a title, which is always at the top of the list. As one of the suggested comments, do listView.addHeaderView .
it seems that LinearLayout is at the bottom of the navigation box layout, which, I think, is responsible for the list of items shown in the figure. Can someone explain how this will work?
They use LinearLayout as a container to store all TextView s:
private void createNavDrawerItems() { mDrawerItemsListContainer = (ViewGroup) findViewById(R.id.navdrawer_items_list); ... int i = 0; for (int itemId : mNavDrawerItems) { mNavDrawerItemViews[i] = makeNavDrawerItem(itemId, mDrawerItemsListContainer); mDrawerItemsListContainer.addView(mNavDrawerItemViews[i]); ++i; } }
I believe that the reason they use LinearLayout , and to inflate all the elements programmatically, is to easily use separator elements:
private View makeNavDrawerItem(final int itemId, ViewGroup container) { ... if (itemId == NAVDRAWER_ITEM_SEPARATOR) { layoutToInflate = R.layout.navdrawer_separator; } else if (itemId == NAVDRAWER_ITEM_SEPARATOR_SPECIAL) { layoutToInflate = R.layout.navdrawer_separator; } else { layoutToInflate = R.layout.navdrawer_item; } ... return view; }
In a ListView you will need to create a separate item type and use a separation layout there, which can become more cumbersome.
At first glance , however, this code simply reinvents the wheel, since all this is possible with the ListView .
Simas
source share