Reputation: 3626
was trying the drawer layout example mentioned in here
After trying this out, I added a few elements, like a button, to the main layout. This is what I did :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin" >
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:onClick="openTestButtonActivity"
android:text="@string/testing" />
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
.
.
.
</android.support.v4.widget.DrawerLayout>
</RelativeLayout>
Now, the drawer works good, but I am not able to activate my button. Is there anything in the ordering of layouts that I am doing wrong ?
Upvotes: 1
Views: 1371
Reputation: 3199
Yes, layout order is wrong. In relativeLayout views are ordered like are added in code. So if you add button first and then you add drawerLayout, drawerLayout overlays button. So you should add DrawerLayout first and then Button.
Upvotes: 2