有什么办法可以使抽屉从上到下滑动?从顶部的Android SlidingDrawer?
回答
默认SlidingDrawer
类不允许这样做。您可以使用Panel
类从这里得到一些非常相似,但:
http://code.google.com/p/android-misc-widgets/
你有没有在那里工作的面板?我很难整合这个面板,虽然这看起来很酷。我的问题在这里,如果有人可以查看它http://code.google.com/p/android-misc-widgets/issues/detail?id=9错误说“二进制XML文件行#15:内容属性是必需的,必须提及有效的孩子。“ – OneWorld 2010-11-04 09:06:29
我不得不将面板小部件包装到一个框架布局以使其工作 – OneWorld 2010-11-25 15:04:46
顶部滴管有一个不需要的行为:下面的内容被移动到底部。我是这样修复的:
我必须为我的项目之一做同样的,我结束了写我自己的小工具这一点。我叫它SlidingTray现在是我的开源Aniqroid库的一部分。
http://aniqroid.sileria.com/doc/api/(查找下载的底部或使用谷歌代码项目,看到更多的下载选项:http://code.google.com/p/aniqroid/downloads/list)
类文档是在这里:http://aniqroid.sileria.com/doc/api/com/sileria/android/view/SlidingTray.html
我试过这个,但是当我使用xml示例实现它时,我在'com.sileria.android.Resource.getIdentifier'处得到了'nullpointer exception'。愿意使用这个。 – Peterdk 2011-08-31 11:25:57
糟糕,看起来像我忘了'Kit.init()'...现在伟大的工程! – Peterdk 2011-08-31 11:34:08
此外,如果您从文档中复制/粘贴XML示例,它是'com.sileria.android.view.SlidingTray'而不是'com.sileria.android.SlidingTray' – Fr4nz 2013-06-17 13:16:31
我已经找到了一种简单的方法来做到这一点。您所要做的就是为slidingDrawer,内容和句柄设置180º的旋转角度。通过一个示例更容易理解,所以看看我做了什么:
首先,我会告诉你我的旧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>
请注意,我还创建了一个的LinearLayout设置为手柄,并没有改变它的旋转中是旋转的,但我改变它的孩子的旋转。这是为了防止我有一个小问题,但一切工作正常,很简单。
我很不满意这里提供的解决方案:
- 从http://code.google.com/p/android-misc-widgets/的
Panel
类是真正直观使用,并在所有 有错误和视觉的干扰信号(不能用于生产用途),并没有文档从
http://aniqroid.sileria.com/doc/api/
SlidingTray
类是嵌套在一个lib需要太多的依赖,对我来说,我没有得到它在使用android:rotation="180"
所有- 工作需要API等级11,我的目标是10
(没有冒犯到各自的开发者,试图在这里的目标)
所以我的解决办法是从这个LIB http://aniqroid.sileria.com/doc/api/(由艾哈迈德·沙基勒)和 提取SlidingTray重构它一下,因为它有一些怪癖需要在Ahmed的lib中使用。 SlidingTray
是基于Android自己的SlidingDrawer
,所以我想它是稳定的。我的修改由1个类组成,我称其为MultipleOrientationSlidingDrawer
和 ,您必须在您的attrs.xml中添加declare-styleables。除此之外,它与使用附加“方向”属性的SlidingDrawer 具有几乎相同的用法。
检查出来:MultipleOrientationSlidingDrawer (source & example) @ 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>
免责声明:所有的学分转到相应的开发。我没有广泛地测试这个解决方案,它的工作原理很好 在XML中设置了TOP和BOTTOM。我没有尝试以编程方式使用它。
这是好的,但你看到动画的问题?您在移动时是否找到了闪烁视图的解决方案? – Vetalll 2013-09-30 11:55:30
我的确有闪烁的http://code.google.com/p/android-misc-widgets/,但与此apporach(到目前为止)的指示 – for3st 2013-10-21 14:45:12
是否有可能使'FrameLayout' content_c'不能占用所有可用空间,因为我看到它将所有东西都拉下来,即使我设置了'android:layout_height =“wrap_content”' – Erik 2017-08-15 13:54:24
- 1. SlidingDrawer顶部
- 2. Android SlidingDrawer
- 3. Android,SlidingDrawer
- 4. Android SlidingDrawer
- 5. Android SlidingDrawer how-to
- 6. 部分“打开”SlidingDrawer
- 7. Slidingdrawer与FragmentActivity在Android
- 8. 如何让Android SlidingDrawer从左侧滑出?
- 9. 的Android SlidingDrawer不“下”抽屉
- 10. jQuery Animate顶部(从底部到顶部)
- 11. Android:从顶部滑动抽屉
- 12. 如何使SlidingDrawer透明
- 13. 从父顶部
- 14. Android SlidingDrawer默认状态?
- 15. SlidingDrawer上方其他视图
- 16. 的SlidingDrawer
- 17. 只显示SlidingDrawer的一部分?
- 18. 动画从底部到顶部而不是从顶部到底部的高度
- 19. 如何从底部从底部动画弹出窗口顶部的Android
- 20. Rezize NSWindow从顶部
- 21. slideindown哇从顶部
- 22. Android的ListView与搜索内SlidingDrawer
- 23. 在Android中的SlidingDrawer下禁用图层
- 24. MATLAB的treeplot:从顶部
- 25. Rotate3d()从顶部的div
- 26. Android导航栏顶部
- 27. Android Wear顶部通知
- 28. Android ListView滚动到顶部
- 29. SlidingDrawer中的按钮
- 30. GoogleMap上的SlidingDrawer
你可以看看https://github.com/Ali-Rezaei/SlidingDrawer,它可以让你从任何一方滑动。 – Ali 2015-06-13 19:12:01