Top-most and Bottom-most Horizontal Divider does not show up in ListView

前端 未结 5 783
情话喂你
情话喂你 2021-02-08 21:49

I am using a ListView. But the top-most and bottom-most horizontal bar does not show up. Why? I am using this:

android:divider=\"@android:drawable/divider_horiz         


        
5条回答
  •  遇见更好的自我
    2021-02-08 22:02

    Here's how I implemented it... Bottom divider shows up after setting android:paddingBottom for the ListView. BUT in my case after setting android:paddingTop top and bottom dividers are not showing. I don't know why. So I added in my list_item_layout.xml the following code:

    
    

    and in my adapter I just changing the visibility of this view:

    View topDivider = v.findViewById(R.id.divider);
    
    if (position == 0) {
        topDivider.setVisibility(View.VISIBLE);
    } else {
        topDivider.setVisibility(View.GONE);
    }
    

    Hope this will helpfull to someone.

提交回复
热议问题