Android的 - 滚动/移动的ListView本身 [英] Android - Scroll/Move the ListView itself

查看:132
本文介绍了Android的 - 滚动/移动的ListView本身的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到了一些现代Android和iOS应用中会有一个图像在覆盖屏幕的整个宽度的页的顶部。在其下方,将会有一个的ListView ,绵延一路下跌到页面。

I have seen some modern Android and iOS applications where there will be an Image at the top of the page that covers the entire width of the screen. Beneath it, there will be a ListView that stretches all the way down to the page.

当你开始对的ListView 向下滚动,在的ListView 自身开始,直到它击中向上发展在屏幕上方,即完全覆盖在上面的屏幕。

When you start to scroll downwards on the ListView, the ListView itself starts to move upwards until it hits the top of the screen, i.e. completely covering the top screen.

这是做到这一点的应用程序的例子是:谷歌 播放 商品 赫芬顿 发表的YouTube

Examples of apps that do this are: Google Play Store, Huffington Post, YouTube.

我试着在Google上搜寻这一点,但没有设法找到一个相对的发射源。

I've tried googling this but haven't managed to find an relative source.

推荐答案

这是一个有点视觉欺骗,它似乎为图像和列表中是一体的,但他们真的不。

This is a bit of visual trickery, where it seems as the image and list are one but they are really not.

基本上你有一个headerview列表视图大小相同的形象,下面你有你的形象的列表视图,从而滚动其显示在列表视图中滚动到图像上。

basically you have a listview with a headerview the same size as the image and below the listview you have your image so as you scroll it appears the listview is scrolling over the image.

布局会是这个样子

<RelativeLayout>

    <ImageView></ImageView>

    <ListView></ListView>

</RelativeLayout>

的创建是空与ImageView的大小

The create another layout for the header that is empty with the size of the imageview

您也可以将图像中的Y方向时,列表滚动但你​​必须在全球范围内守住视图类,因此您可以使用翻译 v.setTranslateY()

You can also Translate the image in the Y direction when the list scrolls but then you have to hold onto the view globally in your class so you can translate using v.setTranslateY()

这篇关于Android的 - 滚动/移动的ListView本身的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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