I have a view which is populated by a ListView
and HeaderView
, my problem is a left margin is applied to the HeaderView
from unknown source because I have not applied any layout margin or padding to the layout, neither via xml
nor programmatically.
so is this a normal ListView
behavior ?
Listview layout
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="@ id/archos_list_view"
style="@style/ArchosGridView"
android:layout_alignWithParentIfMissing="true"
android:divider="@null"
android:dividerHeight="@dimen/content_list_vertical_spacing_between_items" />
</RelativeLayout>
CodePudding user response:
I found the issue by doing breakpoint to find the parent of the headerview and found the ListView which was the source of the issue, it was the style="@style/ArchosGridView"
that was applied to the ListView
, so here is the source of the issue
ArchosGridView
<style name="ArchosGridView">
<item name="android:id">@id/browser_items</item>
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">match_parent</item>
<item name="android:paddingTop">10dip</item>
<item name="android:paddingLeft">@dimen/content_list_left_margin</item>
<item name="android:paddingRight">@dimen/content_list_right_margin</item>
<item name="android:clipToPadding">false</item>
<item name="android:textSize">18sp</item>
<item name="android:drawSelectorOnTop">false</item>
<item name="android:fastScrollEnabled">false</item><!-- true lead to errors on 4.0 -->
<item name="android:choiceMode">singleChoice</item>
<item name="android:cacheColorHint">#00000000</item>
<item name="android:textFilterEnabled">true</item>
<item name="android:scrollbarStyle">outsideOverlay</item>
</style>
the issue was the @dimen/content_list_left_margin of 4 dip was applied (exactly the amount that I expected) but the right one was 0,
<dimen name="content_list_left_margin">4dip</dimen>
<dimen name="content_list_right_margin">0dip</dimen>
so I changed the 4dip
to 0dip
and problem solved