android - Custom Drawer Layout - Click transparency -
i use drawer layout in project. want customize drawer google+ android app. on "main" listview i've added imageview. that's work fine. code is:
<android.support.v4.widget.drawerlayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/drawer_layout" android:layout_width="match_parent" android:layout_height="match_parent" > <framelayout android:id="@+id/content_frame" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <relativelayout android:id="@+id/drawer_layout_relative" android:layout_width="240dp" android:layout_height="wrap_content" android:layout_gravity="start" > <imageview android:id="@+id/drawer_header_image" android:layout_width="wrap_content" android:layout_height="85dp" android:src="@drawable/ic_logo_blue" /> <progressbar android:id="@+id/drawer_progress" style="?android:attr/progressbarstylelarge" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@id/drawer_header_image" android:background="#ffffffff" /> <listview android:id="@+id/drawer_listview" android:layout_width="240dp" android:layout_height="match_parent" android:layout_below="@id/drawer_progress" android:background="#ffffffff" android:choicemode="singlechoice" /> </relativelayout>
when click on 1 of listview-items fragment load framelayout. thats work perfectly, too. there 1 problem. imageview "clickable" too. that, when drawer open, 1 click on imageview listview (on fragment) behind clicked!! don't want that. have try clickable:false on imageview. don't work...
for little demo here video: http://www.vidup.de/v/ao71r/
how can make imageview don't clickable?!
in order keep clicks being passed through drawer view behind it, have setclickable true view in drawer, parent view of other views have in drawer, consumes touch events if none of children consume them.
change relativelayout code drawer_layout_relative following (note: added android:clickable="true" relative layout):
<relativelayout android:id="@+id/drawer_layout_relative" android:layout_width="240dp" android:clickable="true" android:layout_height="wrap_content" android:layout_gravity="start" >
by default, if view not handle clicks, lets clicks go view behind it. have imageview, progressbar, , listview: listview handles click events, consumes touches on it. progressbar , imageviews default display stuff , don't handle clicks them, system passes click list have behind drawer. 3 views inside relativelayout. if set relativelayout clickable, collects click events aren't handled imageview , progressbar , doesn't let click events go view underneath it.
think of android:clickable="true" way block interaction view underneath view set on.
for further explanation, please see this question
Comments
Post a Comment