0

Hii朋友正在创建滑动抽屉我想在左上角设置它的句柄如何在那里设置我使用了相对布局并且它的属性 android:layout_alignParentLeft & android:layout_alignParentTop 不支持所以我如何在下面设置句柄是我的xml代码

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<RelativeLayout        
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/title"
    android:orientation="horizontal" >              


    <TextView
        android:layout_width="wrap_content"
        android:layout_height="50dp"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:gravity="center"
        android:text="Home"
        android:textColor="#ffffff"
        android:textSize="20dp"
        android:textStyle="bold" />

    <ImageView
        android:layout_width="50dp"
        android:layout_height="50dp"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:id="@+id/icon"            
        android:src="@drawable/ic_launcher" />                 
</RelativeLayout>

   <SlidingDrawer
       android:id="@+id/slider"
       android:rotation="180"
       android:layout_width="fill_parent"
       android:layout_height="fill_parent"
       android:layout_alignParentLeft="true"
       android:layout_alignParentTop="true"
       android:content="@+id/content"
       android:handle="@+id/handle"
       android:orientation="horizontal"
       >           

       <include
           android:id="@+id/content"
           layout="@layout/slider" />

       <ImageView
           android:id="@+id/handle"
           android:layout_width="50dp"                             
           android:layout_height="50dp"               
           android:src="@drawable/handle" />          
   </SlidingDrawer>

4

2 回答 2

0

非自定义的 SlidingDrawer 只能在底部或右侧有手柄。

您可能想看看来自 misc-widgets 的面板https://code.google.com/p/android-misc-widgets/

否则,您必须将 SlidingDrawer 旋转 180 度

android:rotation="180"

遗憾的是,这仅适用于 Android 3.0+(API 级别 11)

于 2013-06-20T11:20:51.700 回答
0

无法以这种方式自定义 SlidingDrawable,但您可以旋转 SlidingDrawable 及其句柄和内容。例如:

<SlidingDrawer xmlns:android="http://schemas.android.com/apk/res/android"
   android:id="@+id/slidingDrawer"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:orientation="vertical"
   android:gravity="center_horizontal"
   android:handle="@+id/handle"
   android:content="@+id/content"
   android:rotation="180">

   <LinearLayout
      android:id="@+id/handle"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:gravity="left" >

      <ImageView android:id="@+id/imageView"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:src="@drawable/ic_launcher"
         android:rotation="180" />
   </LinearLayout>

   <ImageView android:id="@+id/content"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:background="#FF0000"
      android:src="@drawable/ic_launcher"
      android:rotation="180" />
</SlidingDrawer>
于 2013-08-28T13:47:31.850 回答