Fix incorrect tab highlight in QuickContactActivity.
Selected highlight is on wrong tab after rotation. Inherently, view pager
remembers the last selected tab. But the highlight is done outside the
view pager and logic was missing to highlight properly when re-creating
from rotation.
Bug: 7206995
Change-Id: Ic016ddb743c323beba71ca95a0a1ae08566a7b1d
diff --git a/res/layout-sw580dp/quickcontact_activity.xml b/res/layout-sw580dp/quickcontact_activity.xml
index a97d86c..129a6e5 100644
--- a/res/layout-sw580dp/quickcontact_activity.xml
+++ b/res/layout-sw580dp/quickcontact_activity.xml
@@ -42,6 +42,7 @@
android:background="@color/quickcontact_tab_indicator" />
<android.support.v4.view.ViewPager
android:id="@+id/item_list_pager"
+ android:background="@color/quickcontact_list_background"
android:layout_width="match_parent"
android:layout_height="160dip" />
</LinearLayout>
diff --git a/src/com/android/contacts/quickcontact/QuickContactActivity.java b/src/com/android/contacts/quickcontact/QuickContactActivity.java
index 16814dc..37417c2 100644
--- a/src/com/android/contacts/quickcontact/QuickContactActivity.java
+++ b/src/com/android/contacts/quickcontact/QuickContactActivity.java
@@ -587,13 +587,18 @@
final CheckableImageView actionView = getActionViewAt(position);
mTrackScroller.requestChildRectangleOnScreen(actionView,
new Rect(0, 0, actionView.getWidth(), actionView.getHeight()), false);
+ renderSelectedRectangle(position, 0);
}
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
+ renderSelectedRectangle(position, positionOffset);
+ }
+
+ private void renderSelectedRectangle(int position, float positionOffset) {
final RelativeLayout.LayoutParams layoutParams =
(RelativeLayout.LayoutParams) mSelectedTabRectangle.getLayoutParams();
- final int width = mSelectedTabRectangle.getWidth();
+ final int width = layoutParams.width;
layoutParams.leftMargin = (int) ((position + positionOffset) * width);
mSelectedTabRectangle.setLayoutParams(layoutParams);
}