Sunday, 11 January 2015

DrawerLayout not clickable after Fragment load



I followed the android guideline and completed a layout looks like this:



android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">

<android.support.v7.widget.Toolbar
android:id= "@+id/my_awesome_toolbar"
android:layout_height="wrap_content"
android:layout_width="match_parent"
/>

<FrameLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/fragmentContainer"/>

</LinearLayout>

<LinearLayout
android:id="@+id/left_drawer_view"
android:layout_width="250dp"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_gravity="start">

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="2"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/wall"
android:layout_margin="0dp"
android:padding="0dp"
android:scaleType="center"
/>

<ImageView
android:layout_width="60dp"
android:layout_height="60dp"
android:src="@drawable/placeholder"
android:layout_margin="16dp"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="IGuessI'mUsername?"
android:textColor="#fff"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_margin="10dp"/>
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="5"
android:orientation="vertical"
android:background="#fff"
android:id="@+id/left_drawer_item"
>

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/side_item_home"
android:text="Home"
android:drawablePadding="5dp"
android:padding="5dp"
android:gravity="center_vertical"
android:drawableLeft="@drawable/ic_menu_home"/>

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Activities"
android:drawablePadding="5dp"
android:id="@+id/side_item_activities"
android:padding="5dp"
android:gravity="center_vertical"
android:drawableLeft="@drawable/ic_menu_search_holo_light"/>

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Settings"
android:drawablePadding="5dp"
android:id="@+id/side_item_settings"
android:padding="5dp"
android:gravity="center_vertical"
android:drawableLeft="@drawable/ic_action_settings"
/>


</LinearLayout>

</LinearLayout>


</android.support.v4.widget.DrawerLayout>


FYI, I did not use Android.R.Id, but my own R.id.fragmentContainer to load the fragments. But apparently, the drawer layout is under the fragment loaded in the FrameLayout. If I click the item on the drawerlayout, the fragments receive the gesture, not the drawerlayout, although it still display correctly.


I need your two cents, guys. All answers and comments are appreciated.


No comments:

Post a Comment