从顶部的Android SlidingDrawer?
有什么办法可以使抽屉从上到下滑动?
默认的SlidingDrawer类不允许这样做。 你可以从这里使用Panel类获得非常相似的东西: http : //code.google.com/p/android-misc-widgets/ 
我find了一个简单的方法来做到这一点。 您只需要为slidingDrawer,内容和句柄设置180º的旋转angular度。 用一个例子来理解就更容易了,所以看看我做了什么:
首先,我将向您展示我的旧SlidingDrawer,从底部到顶部。
 <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"> <ImageView android:id="@+id/handle" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/ic_launcher" /> <ImageView android:id="@+id/content" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="#FF0000" android:src="@drawable/ic_launcher" /> </SlidingDrawer> 
现在看看我所做的更改,设置180º的旋转
 <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="wrap_content" android:layout_height="wrap_content"> <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> 
请注意,我也创build了一个LinearLayout来设置为句柄,并没有改变它的旋转,但我改变了它的孩子的旋转。 这是为了防止我有一个小问题,但一切工作正常,这很简单。
我对这里提供的解决scheme非常不满意:
-   http://code.google.com/p/android-misc-widgets/中的;Panel类实际上使用起来很不直观,而且还存在错误和可视错误(无法用于生产用途),并且根本没有文档
-  来自http://aniqroid.sileria.com/doc/api/的; SlidingTray类被嵌套在一个需要太多依赖的库中,对我来说我根本没有得到它
-  使用android:rotation="180"需要API Level 11,我的目标是10。
(对各个开发者没有冒犯性,试图在这里客观)
 所以我的解决scheme是从这个库http://aniqroid.sileria.com/doc/api/(Ahmed Shakil)提取SlidingTray ,并重构了一下,因为它有一些需要在Ahmed的lib中使用的怪癖。  SlidingTray基于Android自己的SlidingDrawer ,所以我想它是稳定的。 我的修改由一个我称为MultipleOrientationSlidingDrawer类组成,您必须在您的attrs.xml中添加declare-styleables。 除此之外,它与SlidingDrawer的附加“方向”属性具有几乎相同的用法。 
检查出来: MultipleOrientationSlidingDrawer(源&示例)@ gist
这里是一个用法示例(也在要点中提供)
 <your.app.MultipleOrientationSlidingDrawer xmlns:custom="http://schemas.android.com/apk/res-auto/your.app" android:layout_width="match_parent" android:layout_height="match_parent" custom:handle="@+id/handle_c" custom:content="@+id/content_c" custom:orientation="top"> <RelativeLayout android:id="@id/handle_c" android:layout_width="match_parent" android:layout_height="30dp" android:background="#333333"> <TextView android:layout_width="wrap_content" android:layout_height="match_parent" android:text="Handle Text" android:gravity="left|center_vertical"/> </RelativeLayout> <FrameLayout android:layout_width="match_parent" android:layout_height="match_parent" android:id="@id/content_c" android:background="#555555"> <ListView android:id="@+id/listview_credits" android:layout_width="match_parent" android:layout_height="match_parent"/> </FrameLayout> </your.app.MultipleOrientationSlidingDrawer> 
免责声明:所有学分转到各自的开发。 我没有广泛地testing这个解决scheme,它在XML中设置的TOP和BOTTOM很好用。 我没有尝试以编程方式使用它。
我必须为我的一个项目做同样的事情,最后我写了自己的小部件。 我把它称为SlidingTray现在是我的开源Aniqroid库的一部分。
http://aniqroid.sileria.com/doc/api/ (在底部查找下载内容或使用Google代码项目查看更多下载选项: http : //code.google.com/p/aniqroid/downloads/list )
类文档在这里: http : //aniqroid.sileria.com/doc/api/com/sileria/android/view/SlidingTray.html