在Android中将一个片段滑到另一个片段上 [英] sliding one fragment over another in Android

查看:98
本文介绍了在Android中将一个片段滑到另一个片段上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在android中,我们可以在另一个片段上滑动一个片段吗?例如,在下图中:

In android, can we slide a fragment over another? For example, in the following image :

有两个片段.一个是红色,另一个是蓝色.如果用户将手指按在黑色箭头上并将其向右拖动,则红色片段也会随之拖动,从而覆盖蓝色片段.最后,红色片段覆盖了整个蓝色片段.同样,如果用户在红色片段被拖到少于蓝色片段的一半之前抬起手指,则红色片段应回到其原始位置(因此不会覆盖蓝色片段).但是,如果用户直到红色片段覆盖了蓝色片段的一半以上或整个蓝色片段时才松开手指(即,拖动箭头),则红色片段应覆盖整个蓝色片段.

There are two fragments. One is red colored, and the other blue colored. If the user presses his finger on the black colored arrow and drags it to the right, the red colored fragment also drags along with it, thereby covering the blue fragment. In the end, the red fragment covers the whole blue fragment. Also, if the user lifts his finger before the red fragment has been dragged onto less than half of the blue fragment, the red fragment should come back to its original place (and thus not cover the blue fragment). However if the user does not lift his finger (i.e. drags the arrow) till the red fragment covers more than half of the blue fragment, or the whole blue fragment, then the red fragment should cover the whole blue fragment.

此外,如果在红色片段上有任何视图(例如ButtonsEditTexts等),则它们也将相应地调整大小.

Also, if there are any views on the red colored fragment (like, Buttons, EditTexts etc.), then they will also get re-sized accordingly.

有没有办法做到这一点?如果是,那怎么办?

Is there any way to do this? If yes, then how?

推荐答案

您是否看过使用或扩展SlidingDrawer?您可以将红色的片段作为抽屉的内容,而将黑色的箭头作为手柄.

Have you looked at using or extending SlidingDrawer? You could have the red fragment as the content of the drawer and the black arrow as the handle.

这篇关于在Android中将一个片段滑到另一个片段上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆