2013-06-20 73 views
0

斐伊川朋友正在创建滑动抽屉我想设置它的处理在左上角如何设置在那里,我已经使用相对布局,它的性能的android:layout_alignParentLeft &安卓layout_alignParentTop不支持所以,我怎么可以设置如下处理有我的XML代码SlidingDrawer手柄不左上角显示

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

回答

0

非定制SlidingDrawer只能有它的手柄底部或右侧。

您可能希望从其它的小部件来看看面板https://code.google.com/p/android-misc-widgets/

否则,您必须旋转你的SlidingDrawer 180度

android:rotation="180" 

可悲的是,这只是在Android平台所提供3.0+(API等级11)

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>