Advertisement
Ankhwatcher

Applying an outline to an elevated View.

Jul 2nd, 2014
354
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.65 KB | None | 0 0
  1. ivAdd.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
  2.                 @Override
  3.                 public void onLayoutChange(View view, int i, int i2, int i3, int i4, int i5, int i6, int i7, int i8) {
  4.                     if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) {
  5.                         ivAdd.setClipToOutline(true);
  6.                         Outline outline = new Outline();
  7.                         outline.setOval(0,0,ivAdd.getWidth(),ivAdd.getHeight());
  8.                         ivAdd.setOutline(outline);
  9.                     }
  10.                     ivAdd.removeOnLayoutChangeListener(this);
  11.                 }
  12.             });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement