This is the layout of my navigation drawer:
<?xml version="1.0" encoding="utf-8"?>
<!-- the root view is now a LinearLayout, all other Views are children of this -->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:background="#121314"
android:orientation="vertical">
<!-- a separate section to go above the list -->
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="10dp">
<!-- your image, you can set it later (see NavDrawerFrag) -->
<ImageView
android:id="@+id/nav_image"
android:layout_width="150dp"
android:layout_height="150dp"
android:padding="15dp"
android:src="@android:drawable/ic_menu_myplaces"/>
<!-- a bit of test or a title to go with it
<TextView
android:id="@+id/nav_text"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:text="Default text"/>-->
</LinearLayout>
<!-- some divider thing
<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:padding="20dp"
android:background="#000000"/>-->
<!-- your ListView is now a child View -->
<ListView
android:id="@+id/nav_listView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:dividerHeight="0dp"
android:listSelector="@drawable/colors"/>
</LinearLayout>
I want a custom font in the ListView
, but I've been busting my head for two days straight on this. I just can't seem to get it working.
This is the part where the Navigation Drawer is created:
public View onCreateView(LayoutInflater inflater,
ViewGroup container,
Bundle savedInstanceState)
{
// need site names for list
siteNames = getActivity().getResources().getStringArray(R.array.site_names);
Log.d(TAG, "number of sites loaded: " + siteNames.length);
// inflate the parent view (the entire layout)
View view = inflater.inflate(R.layout.fragment_navigation_drawer, container, false);
// now grab the separate child views from inside it
mDrawerListView = (ListView) view.findViewById(R.id.nav_listView);
mDrawerImage = (ImageView) view.findViewById(R.id.nav_image);
//mDrawerText = (TextView) view.findViewById(R.id.nav_text);
// configure the Views
mDrawerImage.setImageResource(R.drawable.orange);
mDrawerListView.setOnItemClickListener(this);
mDrawerListView.setAdapter(new ArrayAdapter<String>(getActionBar().getThemedContext(),
android.R.layout.simple_list_item_1, android.R.id.text1, siteNames));
mDrawerListView.setItemChecked(mCurrentSelectedPosition, true);
// and return the inflated view up the stack
return view;
}