android - ListView header - different margin -


I am creating a layout with a listview and some other ideas I want the full layout to scroll through the list , So I'm adding other scenes as headers. The problem is that there is some margin in my list view, which also applies in the header.

Does it currently look like

So that the header looks like this -

what do i want < P> List View

  & lt; LinearLayout xmlns: android = "http: // schema .android.com / apk / res / android" Android: orientation = "vertical" Android: layout_width = "match_parent" android: layout_height = "match_parent" Android: background = "@color / Background_color "& gt; & Lt; Android: layout_width = "match_parent" Android: layout_height = "wrap_content" android: layout_marginRight = "10dp" Android: layout_marginLeft = "10dp" Android: Scrollbar = "none" Android: id = "@ + id / lvProfileAddresses" Android: Android: cacheColorHint = "@color / background_color" android: fadingEdgeLength = "Android": paddingBottom = "10dp" Android: clipToPadding = "false" "3dp" /> & Lt; / LinearLayout & gt;   

Header

  & lt ;? Xml version = "1.0" encoding = "UTF-8"? & Gt; & Lt; LinearLayout xmlns: Android = "http://schemas.android.com/apk/res/android" Android: Orientation = "Vertical" Android: layout_width = "match_parent" Android: layout_height = "match_parent" Android: background = "@color / Transparent "& gt; & Lt; Android: textSize = "20sp" Android: Padding = "10dp" Android: TextView = "match_parent" android: layout_height = "wrap_content" Android: background = "@color / white" Android: text = "my address" Color = "@color / black" /> & Lt; Android: layout_width = "match_parent" android: layout_height = "wrap_content" android: text = Android "Add new address": drawableRight = "@ drawable / small_list_arrow" Android: layout_margin = "5dp" Android: paddingTop = "5dp" Android: PaddingBottom = "5dp" Android: background = "@drawable / linerlayout_shadow" /> & Lt; / LinearLayout & gt;   

How is a separate margin created in the list view header? I think it would be better to add a header to a list view and place a different header. You may use include for this.

Something like this:

  & lt; Android: layout_height = "match_parent" Android: background = "@color / android" Background_color "& gt; Id = "@ + id / header" Android: layout_width = "match_parent" android: layout_height = "wrap_content" android: layout_alignParentTop = "true" layout = "@ layout / header" /> & Lt; Android included & lt; Android: layout_width = "match_parent" Android: layout_height = "wrap_content" android: layout_marginRight = "10dp" Android: layout_marginLeft = "10dp" Android: Scrollbar = "none" Android: id = "@ + id / lvProfileAddresses" Android: Android: cacheColorHint = "@color / background_color" android: fadingEdgeLength = "Android": paddingBottom = "10dp" Android: clipToPadding = "false" "3dp" /> & Lt; / LinearLayout & gt;   

You should only be on top of list V once. So I hope this will be a better approach hope that it will be helpful.

Edit:

As you need to keep the header in the ListView to scroll with ListView items, you might go through other ways:

>

  • Extract the margin properties from the entire ListView.

  • Apply the margin to ListView in row_item.xml For this, you must enter your line. The external container of XML will need to be included in the containers of any other parent, call the linear layout. Then the margin will work.

    Hope it helps.

  • Comments

    Popular posts from this blog

    java - ImportError: No module named py4j.java_gateway -

    python - Receiving "KeyError" after decoding json result from url -

    .net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -