I have a standard navigation drawer. It's a ListView
:
<ListView android:id="@+id/fragmentLeftDrawer"
android:layout_width="304dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:textStyle="bold"
android:dividerHeight="0dp"/>
populated by drawer_list_item.xml
:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:minHeight="?android:attr/listPreferredItemHeightSmall"
android:padding="10dp">
<ImageView
android:id="@+id/navDrawerImageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_centerVertical="true"
android:paddingStart="16dp"
android:paddingEnd="16dp"/>
<TextView
android:id="@+id/navDrawerTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toEndOf="@+id/navDrawerImageView"
android:paddingStart="16dp"
android:paddingEnd="16dp"/>
</RelativeLayout>
This works fine. Now, I want to replace the ImageView
with something like this Github project. It is essentially a custom class which extends ImageView
. (My class is very similar to the linked project, so for the purposes of this question, just assume they're identical.)
If I replace the ImageView
in drawer_list_item.xml
with something like this:
<package.appname.CustomClass
android:id="@+id/navDrawerCustomImageView"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_centerVertical="true"
android:paddingStart="16dp"
android:paddingEnd="16dp"/>
then, the navigation drawer will not respond to click events. It will only open and close but not navigate to different parts of the apps. No errors or crashes occur.
Does anyone know why this happens? Please let me know. Any advice is appreciated.
Edit: I should mention that I've also tried toggling android:clickable
on my custom ImageView
to see if it had any effect, but no differences arose.