diff options
author | Chris Craik <ccraik@google.com> | 2014-07-11 15:58:05 -0700 |
---|---|---|
committer | Chris Craik <ccraik@google.com> | 2014-07-11 15:58:05 -0700 |
commit | 2a103c177a04a88e5bb5a40e4fb51608137151a8 (patch) | |
tree | 1a125992e29703ecc0ae345a866956d64131b8e6 /src | |
parent | 0b3cd95887159df1e64907d4c866e6d2fedc55ec (diff) |
Move from old setOutline() api to setOutlineProvider()
Change-Id: I9b48309bd54bcb84c781e653df0edb76b163a82c
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/dialer/list/ViewPagerTabs.java | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/src/com/android/dialer/list/ViewPagerTabs.java b/src/com/android/dialer/list/ViewPagerTabs.java index 7e5b5949a..b6b9ab6d4 100644 --- a/src/com/android/dialer/list/ViewPagerTabs.java +++ b/src/com/android/dialer/list/ViewPagerTabs.java @@ -10,6 +10,7 @@ import android.util.AttributeSet; import android.util.TypedValue; import android.view.Gravity; import android.view.View; +import android.view.ViewOutlineProvider; import android.widget.FrameLayout; import android.widget.HorizontalScrollView; import android.widget.LinearLayout; @@ -39,7 +40,15 @@ public class ViewPagerTabs extends HorizontalScrollView implements ViewPager.OnP final boolean mTextAllCaps; int mPrevSelected = -1; int mSidePadding; - Outline mOutline; + + private static final ViewOutlineProvider VIEW_BOUNDS_OUTLINE_PROVIDER = + new ViewOutlineProvider() { + @Override + public boolean getOutline(View view, Outline outline) { + outline.setRect(0, 0, view.getWidth(), view.getHeight()); + return true; + } + }; private static final int TAB_SIDE_PADDING_IN_DPS = 10; @@ -96,7 +105,6 @@ public class ViewPagerTabs extends HorizontalScrollView implements ViewPager.OnP setFillViewport(true); mSidePadding = (int) (getResources().getDisplayMetrics().density * TAB_SIDE_PADDING_IN_DPS); - mOutline = new Outline(); final TypedArray a = context.obtainStyledAttributes(attrs, ATTRS); mTextSize = a.getDimensionPixelSize(0, 0); @@ -108,6 +116,9 @@ public class ViewPagerTabs extends HorizontalScrollView implements ViewPager.OnP addView(mTabStrip, new FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT)); a.recycle(); + + // enable shadow casting from view bounds + setOutlineProvider(VIEW_BOUNDS_OUTLINE_PROVIDER); } public void setViewPager(ViewPager viewPager) { @@ -160,14 +171,6 @@ public class ViewPagerTabs extends HorizontalScrollView implements ViewPager.OnP } @Override - protected void onLayout(boolean changed, int l, int t, int r, int b) { - // An outline is necessary to enable shadows - mOutline.setRect(l, t, r, b); - setOutline(mOutline); - super.onLayout(changed, l, t, r, b); - } - - @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { int tabStripChildCount = mTabStrip.getChildCount(); if ((tabStripChildCount == 0) || (position < 0) || (position >= tabStripChildCount)) { |