0

SlidingDrawerのハンドルであるボタンがあります。SlidingDrawerボタンハンドルと同じ行にアクセスしたい別のボタンがあります。これはLinearLayoutまたはRelativeLayoutでは不可能のようですが、FrameLayoutを介して機能させることができます。

私の問題はこれです:ハンドルボタンは画面の中央にのみ表示されます。各ボタンを画面の反対側に配置します(ボタンのハンドルを右側に、もう一方のボタンを左側に配置します)。このFrameLayoutでラップされたボタンを画面の右側に移動するにはどうすればよいですか?すべてがRelativeLayoutにラップされていますが、このボタンの移動はまだ実現できていません。

関連するAndroidXMLレイアウトコード(もう一度、すべて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>
4

2 に答える 2

1

これは遅いかもしれませんが、私も一度それをひどく必要としていたので、mi8は他の人を助けます

ハンドルボタンの周りにレイアウトを使用しませんでした

追加しました

android:padding='<ディスプレイサイズの3/4>'

あなたのslidingDrawerxmlで

例(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>
于 2012-07-20T13:44:24.623 に答える
-1

追加してみてください

android:orientation="horizontal"

あなたのslidingDrawerxmlで

このリンクも見ることができます、

Android SlidingDrawerを左からスライドさせる方法は?

于 2011-11-21T05:13:39.707 に答える