ListView控件内滚动视图魔术 [英] ListView inside scroll view magic

查看:119
本文介绍了ListView控件内滚动视图魔术的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有关我的应用我想使事情寻找某种方式是这样的:

For my app I want to enable a thing looking somehow like this:

<ScrollView>
    <LinearLayout orientation="vertical">
        <FrameLayout layout_height="48dp">
            Anything I want here...
        </FrameLayout>
        <ListView>
            It's size will be set to screen height anyway
        </ListView>
    </LinearLayout>
</ScrollView>

我想,当用户触摸屏幕滚动,起初只滚动视图滚动,然后,当它达到其一边滚动事件到达的ListView这样做,它begans滚动。

And I want to do so, that when user touches the screen to scroll, at first only scrollview scrolls, and then, when it reaches one of its edges the scroll event goes to listview and it begans scrolling.

我怎样才能做到这一点?

How can I achieve that?

P.S。这样做的原因是为了做出某种隐藏动作条,其中滚动关闭屏幕时,用户的不断深入下去,然后他滚动了它应该出现从底部不与动画,但作为列表移动。所以,如果我滚动列表中的动作条高度的一半 - 我看到屏幕底部的动作条的一半。 你可以明白我的意思在iOS的Google+应用。

P.S. the reason for this is to make some kind of hiding actionbar, which scrolls off the screen when user goes deeper down, and then as he scrolls up it should appear from bottom not with an animation but as the list is moved. so if i scrolled the list half the height of the actionbar - i see the bottom half of the actionbar on the screen. You can see what I mean in iOS Google+ app.

任何帮助将AP preciated。

Any help will be appreciated.

推荐答案

在Layaout设置参数

in Layaout set Parameter

 <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:fillViewport="true" >

      <ListView
                    android:id="@+id/listview"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent">
      </ListView>
</ScrollView>

而在编码部分设置列表视图的动态高度根据设备的高度

And in the Coding Part Set the Dynamic height of listview according to device height

    LayoutParams lp = (LayoutParams) list1.getLayoutParams();
    int height = (arraylist.size()) * 80; 

        //arraylist list is in which all data is kept

    lp.height = height;
    listview.setLayoutParams(lp);

    listview.setAdapter(Adapter);

这篇关于ListView控件内滚动视图魔术的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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