android - 如何更改android slidingdrawer handle 按钮位置

标签 android android-sliding

在抽屉中央的android SlidingDrawer中默认的 handle 按钮。是否可以将该位置更改为向左或向右..?如果可能的话,我该怎么做,android:gravity="left" 在按钮中不起作用。

最佳答案

将你的句柄放在 RelativeLayout 中,并在句柄上设置 android:layout_alignParentRight="true"。

例如像这样:

<?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="wrap_content">

    <TextView android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/hello" />

    <SlidingDrawer android:id="@+id/drawer"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:handle="@+id/handle" 
        android:content="@+id/content">

        <RelativeLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" 
            android:id="@+id/handle">
            <ImageView android:src="@drawable/icon"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentRight="true" />
        </RelativeLayout>

        <LinearLayout 
            android:gravity="center" 
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:background="#aaaa00" android:id="@+id/content">
            <ImageView android:src="@drawable/icon"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="center">
            </ImageView>
        </LinearLayout>

    </SlidingDrawer>

</FrameLayout>

关于android - 如何更改android slidingdrawer handle 按钮位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6894149/

相关文章:

android - 使用 ACTION_SEND 或 ACTION_SEND_MULTIPLE 发送图像和文本

android - 如何获取 android webview url 以自动检测 https http 和 www?

android - 如何实现从右向左滑动菜单

java - 短信中的字符 "|"

android - 使用 android :enabled ="@bool/tablet" or "@bool/phone" supported? 在 list 中有选择地启用 Activity 别名

android - 如果用户卸载应用程序,他们是否会失去应用内购买?

android - 在方向更改时处理多个可交换 fragment 的最佳方法

Android 无法解析符号 getFragmentManager()

java - Android 滑动菜单不适用于平板电脑;菜单就像在普通手机中一样(滑动按钮点击)