android listview 滑动隐藏其它控件问题。
如题,我现在布局是个线性布局,有个Linearlayout,Linearlayout下面是LISTVIEW,listview下面是Linearlayout,很简单的
一个总局。我现在想实现一个功能,当listview下滑或者滑动底的时候最顶上的Linearlayout要自动隐藏消失,之间有个动
画,是慢慢从边缘消失。
我现在直接把这个Linearlayout的可视性设置为GONE,然后加一个动画TranslateAnimation,这样直接导致这个Linearlayout
消失连同它占用的空间大小都没有了。动画根本看不到。相反,当往上滑动就要出现这个Linearlayout,我的方法就是设置它
的可视性为VISIBLE,但是这样的结果是这个Linearlayout会马上把它的大小占用,我们看到效果就是一片黑的,然后动画慢慢
的出现从上往下滑出来。
我本来想动态修改这个Linearlayout的高度,这样可以出现这种效果,但是改变高度背景图片都是压缩的样子,很丑啊。网
上一些帖子说改变坐标,我用的这Linearlayout布局何心改变坐标呢,大家有没有好方法???
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:orientation="vertical">
<include android:id="@+id/pro_head" android:layout_width="fill_parent"
android:layout_height="wrap_content" layout="@layout/head" />
<ListView android:id="@+id/list_product" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_weight="1" />
<include android:id="@+id/pro_bottom" android:layout_width="fill_parent"
android:layout_height="wrap_content" layout="@layout/bottom" />
</LinearLayout>
[解决办法]
给TranslateAnimation动画加监听,
动画结束的时候才把那个顶端布局设置为gone。
而相反的时候 想让一个假的副本布局移动,当他移动结束后的监听里面设置之间gone的布局为VISIBLE
主要我还是没彻底理解你想实现什么效果,比如当滚动listview的时候,这个顶部布局需要同时移动么?
如果是那样的话你可以考虑下把这个顶部布局做成 lisetview的header