本文介绍了添加“橡皮筋"更改应用程序背景时在android中的效果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理以下应用程序:

I am working on the application in which:

用户将可以通过水平滑动BG和垂直滑动文本来更改背景和文本(多个).在这种情况下,如果我要更改BG,则文本应保持不变,如果我要更改文本,则BG应保持不变.

User will have a control to change the background and text (multiples) by doing horizontal swipe for BG and vertical swipe for text. In this case, if I am changing BG, text should remain constant and if I am changing text then BG should remain constant.

此外,我想在用户更改Text和BG时像在iOS中一样添加 Rubber Band effect .

Also, I want to add Rubber Band effect like in iOS when user changes Text and BG.

我正在考虑 twoway-view 库来支持垂直和水平滚动.但是在我的情况下如何使用该库?

I am thinking of twoway-view library to support for vertical and horizontal scrolling. But how to use this library in my case?

任何想法/解决方案将不胜感激.

Any idea/solution will be appreciated.

推荐答案

twoway-view实现了AdapterView,它可以垂直或水平滚动,但不能同时滚动.在您的情况下,它将无法正常工作.

twoway-view implements an AdapterView that can scroll vertically or horizontally, but not both at the same time. It wouldn't work in your case.

我将使用一个ViewPager,其中每个片段:

I would use a ViewPager in which each fragment:

  1. 显示特定背景
  2. 允许用户通过上下滑动手势选择文本.

要获得橡皮筋效果,只需添加 BounceInterpolator 到将文本上移&的动画中;下.在ViewPager中,您可以应用自定义 PageTransformer .

To obtain a rubber band effect, just add a BounceInterpolator to the animation that moves the text up & down. In the ViewPager you could get a similar effect applying a custom PageTransformer.

这篇关于添加“橡皮筋"更改应用程序背景时在android中的效果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-13 13:15