Empty space between listview header and first item

后端 未结 6 1992
青春惊慌失措
青春惊慌失措 2021-02-01 15:11

I\'ve created an android application with a ListView. I\'ve added both a header and footer to the list. But when adding a divider/separator it also creates an empty space betwee

6条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-01 15:35

    I tried a solution by 幻影浪子 that works (based on android-pulltorefresh):

    View Layout (header.xml):

    
    
    
        
    
            
        
    
    

    Inflating View:

    m_headerView = inflater.inflate(R.layout.header, this, false);
    

    Displaying View:

    m_headerView.setPadding(0, 0, 0, 0);
    m_headerView.setVisibility(View.VISIBLE);
    

    Hiding View:

    m_headerView.setPadding(0, -1000, 0, 0);
    m_headerView.setVisibility(View.GONE);
    

    It worked perfectly in our project. I hope it is helpful.

提交回复
热议问题