Fix width of ContactListPinnedHeaderView
CHANGE:
Change ContactListPinnedHeaderView so that it's non-padded width matches
ContactListItemView#mHeaderTextView.
BACKGROUND:
ContactListPinnedHeaderView and ContactListItemView#mHeaderTextView both
represent letter headers. ContactListPinnedHeaderView overlaps
ContactListItemView#mHeaderTextView.
ContactListPinnedHeaderView and ContactListItemView#mHeaderTextView's
header were both given the same width. But ContactListPinnedHeaderView
has starting padding whereas ContactListItemView has a starting margin
(more precisely, it uses a custom layout function to simulate margin).
Therefore, the portion of ContactListPinnedHeaderView
that was used to display text was smaller than ContactListItemView.
Bug: 17393755
Change-Id: I3610ad29058832cebbe8abba537057bb723bd945
diff --git a/src/com/android/contacts/common/list/ContactListPinnedHeaderView.java b/src/com/android/contacts/common/list/ContactListPinnedHeaderView.java
index 1bd7e77..7b4a3cd 100644
--- a/src/com/android/contacts/common/list/ContactListPinnedHeaderView.java
+++ b/src/com/android/contacts/common/list/ContactListPinnedHeaderView.java
@@ -45,13 +45,14 @@
R.styleable.ContactListItemView_list_item_text_offset_top, 0);
int paddingStartOffset = a.getDimensionPixelSize(
R.styleable.ContactListItemView_list_item_padding_left, 0);
+ int textWidth = getResources().getDimensionPixelSize(
+ R.dimen.contact_list_section_header_width);
+ int widthIncludingPadding = paddingStartOffset + textWidth;
a.recycle();
setBackgroundColor(backgroundColor);
setTextAppearance(getContext(), R.style.SectionHeaderStyle);
- setLayoutParams(new LayoutParams(
- getResources().getDimensionPixelSize(R.dimen.contact_list_section_header_width),
- LayoutParams.WRAP_CONTENT));
+ setLayoutParams(new LayoutParams(widthIncludingPadding, LayoutParams.WRAP_CONTENT));
setLayoutDirection(parent.getLayoutDirection());
setGravity(Gravity.CENTER_VERTICAL |
(ViewUtil.isViewLayoutRtl(this) ? Gravity.RIGHT : Gravity.LEFT));