下拉菜单或在幻灯片上查看
我想知道是否有人可以指导我如何完成以下任务,
当用户按住标题栏并向下拖动时,用户有一个标题栏;它向用户展示了不同的视图。这是驻留在 tabhost 中的视图。
它类似于android的默认状态栏。
I was wondering if someone could guide me on how to accomplish the following,
The user has a title bar, when the user holds the title bar and drags down; it shows the user a different view. This is a view residing in a tabhost.
It is similar to android's default statusbar.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您应该尝试使用
ViewFlipper
和RelativeLayout
子项并在header
上附加 OnTouchListeners 来完成此操作(类似 AccordionView 的行为)。这对我有用。示例应用程序
main.xml //在
res/layouts
androidManifest.xml //仅活动声明
AccordionSample.java //你的主要活动
AccordionAnimation.java //用于上下滑动
strings.xml / /inside
res/values
编辑
如果您想将不同的视图拆分为不同的布局 xml,例如
您应该修改您的
onCreate
方法:Edit
或者更优雅、更高效,只需将您为不同视图创建的布局 xml 包含到
main.xml
中:其中
layout/flipping_view_1.xml
包含第一个
RelativeLayout
,和
layout/flipping_view_2.xml
第二个
RelativeLayout
包含原始 main.xml 中
ViewFlipper
的。要了解有关 android 布局的可重用性以及整体布局技术的更多信息,您应该查看 Romain Guy 的精彩帖子,介绍了布局技巧。
You should try to accomplish this (an AccordionView-like behavior) using
ViewFlipper
withRelativeLayout
children and attached OnTouchListeners on theheader
s. It worked for me.Sample application
main.xml //inside
res/layouts
androidManifest.xml //activity declaration only
AccordionSample.java //your main activity
AccordionAnimation.java //for the up and down sliding
strings.xml //inside
res/values
Edit
If you'd like to split your different views into different layout xmls, say
you should modify your
onCreate
method:Edit
or more elegantly and efficiently, simply just include the layout xmls you've created for the different views into your
main.xml
:where
layout/flipping_view_1.xml
contains the first
RelativeLayout
,and
layout/flipping_view_2.xml
contains the second
RelativeLayout
of the
ViewFlipper
inside your original main.xml.To learn more about the reusability of android layouts, and layout techniques overall, you should take a look at Romain Guy's great post covering layout tricks.
请参阅这两篇文章以获取指针 - Android:像软件键盘一样在另一个视图下有一个任意视图幻灯片和如何让我的页面随着用户在屏幕上滑动手指而滑动?
See these two posts for pointers - Android: Have an arbitrary View slide under another View like the software keyboard does and How can I make my page slide as the user slides finger on the screen?