滚动型的Andr​​oid如何保持屏幕组件时,滚动到屏幕的顶部? [英] Android ScrollView how to keep component on screen when it scroll to top of the screen?

查看:99
本文介绍了滚动型的Andr​​oid如何保持屏幕组件时,滚动到屏幕的顶部?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个滚动型的布局是这样,例如:

I have a ScrollView layout like this, for example:

<ScrollView> 
    <Component1>
    <Component2>
    <Component3>
    <Component4>
    ...
</ScrollView>

里面滚动型我有一些组件,他们每个人都能像的LinearLayout,RelativeLayout的,的TableRow,什么...
现在我想的是,我将滚动视图,当&LT; COMPONENT2&GT; 到达屏幕的上方,它会保持在屏幕上,&LT; Component3&GT; &LT; Component4&GT; ...将继续滚动到页的末尾。当我向下滚动,&LT; COMPONENT2&GT; 当所有的&LT将只滚动; Component3&GT; 已显形。我看到这个在iPhone上的应用程序,并想知道如何实现这一点在Android上。

Inside ScrollView I have some components, each of them can be anything like LinearLayout, RelativeLayout, TableRow, ... Now what I want is I will scroll the view, when the <Component2> reach the top of the screen, it will be keep on the screen and <Component3>, <Component4>... will keep scrolling till the end of page. When I scroll down, <Component2> will only be scrolled when all the <Component3> has became visible. I saw this on an Iphone app and wondered how to achieve this on Android.

我不知道如果我描述不够清楚,但它是同样喜欢这部影片

I don't know if I describe clearly enough but it is same like this video

http://www.youtube.com/watch?v=jXCrM1rzLZY&feature=player_detailpage#t=71s

在标签向上滚动到顶部,它呆在那里。而当向下滚动像 1:36 的视频,它呆在那里,直到所有的内容下面已成为显示在屏幕上。

When the tabs scrolled up to top, it stay there. And when scrolled down like in 1:36 of that video, it stay there until all the content below has became visible on the screen.

有人是否知道如何做到这一点在Android?

Does anybody know how to do this on Android?

推荐答案

我想你可以在一个RelativeLayout的是调用setVisible(真)创建COMPONENT2的一个隐藏的副本时,COMPONENT2的坐标较低(Android版从顶部平)比滚动型的顶部。当COMPONENT2的坐标为比滚动型(.getTop()),Component2Copy.setVisible(假)。

I guess you could create a hidden copy of Component2 in a RelativeLayout that is setVisible(true) when the coordinates of Component2 are lower(Android draws from the top) than the top of the ScrollView. When the coordinates of Component2 are higher than the top of the ScrollView (.getTop()), Component2Copy.setVisible(false).

您可能还需要改变自己的知名度时,禁用它们。祝你好运与此有关。

You may also want to disable them when changing their visibility. Good luck with this.

这篇关于滚动型的Andr​​oid如何保持屏幕组件时,滚动到屏幕的顶部?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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