2011-11-21 73 views
0

我有一個Button,它是SlidingDrawer的句柄。我想要在SlidingDrawer按鈕手柄的同一行上訪問另一個按鈕。這對於LinearLayout或RelativeLayout來說似乎不可行,但我可以通過FrameLayout使其工作。將FrameLayout移動到左側(包含SlidingDrawer按鈕的句柄)

我的問題是這樣的:句柄按鈕將只顯示在屏幕的中心。我希望每個按鈕位於屏幕的兩側(按鈕手柄位於右側,而另一個按鈕位於左側)。我該如何將這個FrameLayout-wrapped按鈕移動到屏幕的右側?一切都被包裹在一個RelativeLayout中,但我還沒有能夠實現這個按鈕的移動。

相關的Android XML佈局代碼(再次,所有包裹在一個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> 

回答

1

這可能會遲到,但MI8幫助一些人,因爲我太需要它後發生嚴重

我沒有使用任何佈局在我的手柄按鈕

我只是說

機器人:填充=」 < 3/4個UR顯示尺寸>」

在slidingDrawer XML

實施例的(只是貼到xml和運行):

<?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> 
-1

嘗試增加

android:orientation="horizontal" 

在slidingDrawer XML

你也可以看到這個鏈接,

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

+0

我不希望SlidingDrawer從右向左打開 - 我想要右側的句柄。我希望整個事情從下到上打開,這是標準的方式。 – DashRantic

+0

好吧,看看這是否有助於你http://stackoverflow.com/questions/6894149/how-to-change-android-slidingdrawer-handle-button-position – voidRy

+0

正如我在我的問題所述,我需要兩個按鈕行。正如我在我的問題中所述,RelativeLayout對此沒有幫助。 – DashRantic