</pre>有什么样的需求,就有什么样的对策,折腾了半天时间,终于解决了。。。<p></p><p> sa:listview 上添加一个布局 addheadview(。。),listview是分组显示的 ,listview滚动的同时,分组悬浮起来并且有挤压效果;如图</p><p></p><p><img src="https://img-blog.csdn.net/20140802124336992?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvdGVsZW5jb29s/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="" /></p><p>B部分要去除控件 ,为了解决这个问题</p><p></p><pre name="code" class="html"></pre><pre name="code" class="java"><?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/root_item"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/item_container"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<com.yuedu.boss.comm.views.HorizontalListView
android:id="@+id/horizon_listview"
android:layout_width="match_parent"
android:layout_height="90dip"
android:listSelector="@color/transparent" >
</com.yuedu.boss.comm.views.HorizontalListView>
</LinearLayout>
</LinearLayout>
考虑到兼容性,有些机型隐藏掉后,控件所占用的空间仍然存在,所以特意用linearlayout 包裹一个控件。问题解决了!~~
<span style="font-family: Arial, Helvetica, sans-serif;">需要隐藏
</span><span style="font-family: Arial, Helvetica, sans-serif;">item_container.setVisibility(View.GONE)
</span><span style="font-family: Arial, Helvetica, sans-serif;">item_container .setPadding(0, -itemcontainer.getHeight(), 0, 0);
</span><span style="font-family: Arial, Helvetica, sans-serif;">显示
</span><span style="font-family: Arial, Helvetica, sans-serif;">item_container.setVisibility(View.VISIBLE);
</span><span style="font-family: Arial, Helvetica, sans-serif;">item_container.setPadding(0, 0, 0, 0);</span>