Android - 使滑动抽屉从左向右滑动

Par*_*ani 13 android android-widget android-sliding

我使用下面的XML布局在我的应用程序中实现了"Sliding Drawer":(我从androidpeople.com得到了这个例子)

<LinearLayout android:id="@+id/LinearLayout01"
 android:layout_width="fill_parent" android:layout_height="fill_parent"
 xmlns:android="http://schemas.android.com/apk/res/android"
 android:background="@drawable/androidpeople">

 <SlidingDrawer 
  android:layout_width="wrap_content" 
  android:id="@+id/SlidingDrawer" 
  android:handle="@+id/slideHandleButton" 
  android:content="@+id/contentLayout" 
  android:layout_height="75dip"
  android:orientation="horizontal">

  <Button 
   android:layout_width="wrap_content" 
   android:layout_height="wrap_content" 
   android:id="@+id/slideHandleButton" 
   android:background="@drawable/closearrow">
  </Button>

  <LinearLayout 
   android:layout_width="wrap_content" 
   android:id="@+id/contentLayout" 
   android:orientation="horizontal" 
   android:gravity="center|top" 
   android:padding="10dip" 
   android:background="#C0C0C0" 
   android:layout_height="wrap_content">


   <Button android:id="@+id/Button01" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Content"></Button>
   <Button android:id="@+id/Button02" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Content"></Button>
   <Button android:id="@+id/Button03" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Content"></Button>

  </LinearLayout>

 </SlidingDrawer>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

但我想要的是将抽屉从左向右(水平)而不是从右向左滑动,如何使滑动抽屉从左向右滑动?

请与我分享您的想法/观点/意见/问题,并让我摆脱这个问题.

Upv*_*ote 6

这是一个关于此的教程:链接

似乎滑动抽屉没有定位,我找不到sdk提供的任何布局属性.但是就像在上面的教程中一样,您可以编写自己的滑动抽屉小部件并应用布局属性来定位滑块/面板.


你可以结账https://github.com/umano/AndroidSlidingUpPanel

  • 我已经检查了该链接,其中我没有找到答案中给出的链接上的任何项目/代码,我也没有找到任何关于"水平滑块"的信息 (2认同)

小智 5

您可以将此用于从左到右的抽屉..

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"

android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView 
android:layout_width="50dip"
android:layout_height="50dip"
android:text="@string/hello"
/>
<SlidingDrawer
 android:id="@+id/drawer"
 android:layout_width="fill_parent"
 android:layout_height="wrap_content"
 android:orientation="horizontal"
 android:handle="@+id/handle"     
 android:content="@+id/content">


<ImageView
 android:id="@id/handle"
 android:layout_width="50dip"
 android:layout_height="50dip"  
 android:src="@drawable/icon"
/>

<LinearLayout
 android:id="@id/content"
 android:layout_width="fill_parent"
 android:layout_height="fill_parent"
 android:orientation="vertical">
<Button
 android:layout_width="fill_parent"
 android:layout_height="fill_parent"
 android:text="Big Big Button"/>
</LinearLayout>

</SlidingDrawer>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)


Hes*_*sam 5

最好且简单的解决方案是向 SlidingDrawer 添加一行代码,android:rotation = "180"有关更多信息,请参阅此链接