如何改变安卓slidingdrawer手柄按钮位置 [英] How to change android slidingdrawer handle button position

查看:112
本文介绍了如何改变安卓slidingdrawer手柄按钮位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Android中SlidingDrawer默认的手柄按钮,在抽屉的中心。是否有可能改变位置向左或向右..?如果可能,我怎么能做到这一点,安卓重力=左未在按钮的工作

In default handle button in android SlidingDrawer in the centre of the drawer. Is it possible to change that position to left or right..? If it possible how can I do that, android:gravity="left" is not work in the button.

推荐答案

把你的手柄在RelativeLayout的,并设置机器人:layout_alignParentRight =真上的手柄

Put your handle in a RelativeLayout, and set android:layout_alignParentRight="true" on the handle.

例如是这样的:

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

这篇关于如何改变安卓slidingdrawer手柄按钮位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆