0

I have a Button which is the handle for a SlidingDrawer. I have another button I want to be accessible on the same row as the SlidingDrawer button handle as well. This does not seem possible with a LinearLayout or a RelativeLayout, but I can get it working via a FrameLayout.

My issue is this: the handle button will only display itself in the center of the screen. I want each button to be on opposite sides of the screen (the button handle to be on the right, and the other button to be on the left). How can I move this FrameLayout-wrapped Button to the right of the screen? Everything is wrapped in a RelativeLayout, but I have not been able to achieve this button move yet.

Relevant Android XML layout code (once again, all wrapped in a RelativeLayout):

<Button android:id="@+id/EditListActivityButton"
android:text="@string/mappage_edititems"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="@+id/addItemSlidingDrawerHandle"
android:layout_above="@+id/item">
</Button>

<SlidingDrawer android:id="@+id/addItemSlidingDrawer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:handle="@+id/addItemSlidingDrawerHandle"
android:content="@+id/addItemSlidingDrawerContent"
android:layout_above="@+id/item"
android:layout_alignParentRight="true">

    <FrameLayout android:id="@id/addItemSlidingDrawerHandle"
    android:layout_width="wrap_content"
    android:layout_height="fill_parent"
    android:layout_toRightOf="@+id/goToEditListButton">

        <Button android:id="@+id/addItemSlidingDrawerHandleButton"
        android:text="@string/mappage_additem"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">
        </Button>
    </FrameLayout>

    <LinearLayout android:id="@id/addItemSlidingDrawerContent"
    android:layout_height="fill_parent"
    android:layout_width="fill_parent"
    android:orientation="vertical"
    android:background="#96C120">

    <!-- sliding drawer content goes here -->

    </LinearLayout>

</SlidingDrawer>
DashRantic
  • 1,448
  • 4
  • 19
  • 32

2 Answers2

1

This may be late, but mi8 help some others since Me too needed it badly once

I didnt use any layout around my handle button

I just added

android:padding='<3/4 th of ur display size>'

in your slidingDrawer xml

Example(just paste in a xml and run):

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_width="fill_parent"
 android:layout_height="fill_parent">

 <ImageView 
  android:layout_width="fill_parent"
  android:layout_height="fill_parent" 
  android:src="@drawable/ic_launcher"/>

 <SlidingDrawer
  android:id="@+id/drawer"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:orientation="horizontal"
  android:handle="@+id/handle"
  android:content="@+id/content">
  <ImageView 
   android:id="@id/handle"
   android:layout_width="wrap_content"
   android:layout_height="fill_parent"
   android:paddingBottom="250dp"
   android:src="@drawable/ic_launcher"/>
  <LinearLayout
   android:id="@id/content"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent"
   android:orientation="vertical"
   android:padding="10dp"
   android:background="#55000000">
   <Button
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" 
    android:text=" - Button - "/>
   <Button
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" 
    android:text=" - Button - "/>
   <Button
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" 
    android:text=" - Button - "/>
   <Button
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" 
    android:text=" - Button - "/>
   <Button
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" 
    android:text=" - Button - "/>
   <Button
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" 
    android:text=" - Button - "/>
  </LinearLayout>
 </SlidingDrawer>
</FrameLayout>
Manoj Kumar
  • 1,510
  • 3
  • 20
  • 40
-1

Try adding

android:orientation="horizontal"

in your slidingDrawer xml

You can also see this link,

How to make an Android SlidingDrawer slide out from the left?

Community
  • 1
  • 1
voidRy
  • 674
  • 9
  • 20
  • I don't want the SlidingDrawer to open from right to left--I want the handle on the right side. I want the entire thing to open from bottom to top, the standard way. – DashRantic Nov 21 '11 at 05:23
  • Ok , see if this helps u http://stackoverflow.com/questions/6894149/how-to-change-android-slidingdrawer-handle-button-position – voidRy Nov 21 '11 at 06:21
  • As I stated in my question, I need two buttons in the same row. As I stated in my question, a RelativeLayout does not help with that. – DashRantic Nov 21 '11 at 06:34