android ListView隐藏FooterView(headerView)

安卓开发。正在使用listView时间,我们经常使用的footerView要么headerView

给ListView添加footer和header很多时间。它会基于隐藏和显示的情况下。

因为footer和header感觉不好。

而直接设置footer和header中的view为GONE时,尽管内容不显示了,可是这块区域还是会被占用。

经过各种方法測试。最后得出一个能够完美解决该问题的方法。例如以下代码:

this.footerLayout.setVisibility(View.GONE);
this.footerLayout.setPadding(0, -footerLayout.getHeight(), 0, 0);


意思就是把内容往上移动View的高度。

当然。在须要显示的时候,还要设置回来(做一个if  else处理就可以)

this.footerLayout.setVisibility(View.VISIBLE);
this.footerLayout.setPadding(0, 0, 0, 0);

但问题就解决了真的受伤了~~~~

版权声明:本文博客原创文章。博客,未经同意,不得转载。

posted @ 2015-07-06 13:41  mengfanrong  阅读(561)  评论(0编辑  收藏  举报