List of usage examples for android.view ViewOutlineProvider ViewOutlineProvider
ViewOutlineProvider
From source file:Main.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP) public static void makeCircle(final View view, final int dimenResId) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { ViewOutlineProvider viewOutlineProvider = new ViewOutlineProvider() { @Override/* ww w.j a v a2s . c o m*/ public void getOutline(View view, Outline outline) { Context context = view.getContext(); int size = context.getResources().getDimensionPixelSize(dimenResId); outline.setOval(0, 0, size, size); } }; view.setOutlineProvider(viewOutlineProvider); } }
From source file:Main.java
/** * Adds a rectangular outline to a view. This can be useful when you want to add a shadow * to a transparent view. See b/16856049. * @param view view that the outline is added to * @param res The resources file./*w ww. jav a2s. c om*/ */ public static void addRectangularOutlineProvider(View view, Resources res) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { ViewOutlineProvider rectOutlineProvider = new ViewOutlineProvider() { @Override public void getOutline(View view, Outline outline) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { outline.setRect(0, 0, view.getWidth(), view.getHeight()); } } }; view.setOutlineProvider(rectOutlineProvider); } }
From source file:com.example.toolbardemo.Fragment.ClippingViewFragment.java
private void clippingView() { ViewOutlineProvider viewOutlineProvider = new ViewOutlineProvider() { @Override//from ww w . j a va 2 s . c o m public void getOutline(View view, Outline outline) { outline.setRoundRect(0, 0, view.getWidth(), view.getHeight(), 10); } }; ViewOutlineProvider viewOutlineProvider1 = new ViewOutlineProvider() { @Override public void getOutline(View view, Outline outline) { outline.setRoundRect(0, 0, view.getWidth(), view.getHeight(), view.getHeight() / 2); } }; tv1.setOutlineProvider(viewOutlineProvider); tv2.setOutlineProvider(viewOutlineProvider1); }
From source file:arun.com.chromer.webheads.ui.views.ElevatedCircleView.java
@Override protected void onAttachedToWindow() { super.onAttachedToWindow(); if (Utils.isLollipopAbove()) { setOutlineProvider(new ViewOutlineProvider() { @TargetApi(Build.VERSION_CODES.LOLLIPOP) @Override/*from ww w. j a v a 2 s .co m*/ public void getOutline(View view, Outline outline) { int shapeSize = getMeasuredWidth(); outline.setRoundRect(0, 0, shapeSize, shapeSize, shapeSize / 2); } }); setClipToOutline(true); } }
From source file:com.androidzeitgeist.webcards.overlay.HandleView.java
public HandleView(Context context) { super(context); windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); final Resources resources = getResources(); margin = resources.getDimensionPixelSize(R.dimen.overlay_button_margin); openOffsetX = resources.getDimensionPixelSize(R.dimen.overlay_width); paint = new Paint(); paint.setColor(ContextCompat.getColor(context, R.color.overlayAccent)); paint.setAntiAlias(true);/*from w ww . jav a 2 s.c o m*/ streamBitmap = BitmapFactory.decodeResource(resources, R.drawable.ic_action_stream); openAppBitmap = BitmapFactory.decodeResource(resources, R.drawable.ic_action_open_app); currentBitmap = openAppBitmap; setElevation(resources.getDimensionPixelSize(R.dimen.overlay_button_elevation)); setOutlineProvider(new ViewOutlineProvider() { @Override public void getOutline(View view, Outline outline) { outline.setOval(0, 0, getWidth(), getHeight()); } }); }
From source file:com.ffmpeger.card.utils.LPreviewUtilsBase.java
public void setupCircleButton(ImageButton sourceButton) { if (hasL()) { if (sourceButton != null) { final int size = mActivity.getResources().getDimensionPixelSize(R.dimen.hd_fab_size); sourceButton.setOutlineProvider(new ViewOutlineProvider() { @Override// w w w . j a v a2 s.c o m public void getOutline(View view, Outline outline) { outline.setOval(0, 0, size, size); } }); sourceButton.setClipToOutline(true); } } }
From source file:com.shizhefei.view.coolrefreshview.header.JellyHeader.java
public JellyHeader(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); setWillNotDraw(false);//from www. ja v a2s. c o m defaultMinHeight = Utils.dipToPix(context, 208); mPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mPaint.setStyle(Paint.Style.FILL); mPath = new Path(); showLoadingAnimation = new AlphaAnimation(0, 1); showLoadingAnimation.setDuration(300); showLoadingAnimation.setInterpolator(new AccelerateInterpolator()); hideLoadingAnimation = new AlphaAnimation(1, 0); hideLoadingAnimation.setDuration(300); hideLoadingAnimation.setInterpolator(new DecelerateInterpolator()); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { mViewOutlineProvider = new ViewOutlineProvider() { @TargetApi(Build.VERSION_CODES.LOLLIPOP) @Override public void getOutline(View view, Outline outline) { if (mPath.isConvex()) outline.setConvexPath(mPath); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) { outline.offset(0, totalDistance() - currentDistance); } } }; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { setElevation(Utils.dipToPix(context, 4)); } } }
From source file:com.landenlabs.allperfimages.ui.Ui.java
public static void setRectOutline(View view) { final int width = view.getWidth(); final int height = view.getHeight(); if (Build.VERSION.SDK_INT >= 21) { view.setOutlineProvider(new ViewOutlineProvider() { @Override//from w ww. jav a 2s.com public void getOutline(View view, Outline outline) { if (Build.VERSION.SDK_INT >= 21) { outline.setRect(0, 0, width, height); } } }); } }
From source file:com.android.incallui.CircularRevealActivity.java
private void setupDecorView(final Point touchPoint, MaterialPalette palette) { final View view = getWindow().getDecorView(); // The circle starts from an initial size of 0 so clip it such that it is invisible. When // the animation later starts, this clip will be clobbered by the circular reveal clip. // See ViewAnimationUtils.createCircularReveal. view.setOutlineProvider(new ViewOutlineProvider() { @Override//from ww w . j ava 2 s . c o m public void getOutline(View view, Outline outline) { // Using (0, 0, 0, 0) will not work since the outline will simply be treated as // an empty outline. outline.setOval(-1, -1, 0, 0); } }); view.setClipToOutline(true); if (palette != null) { view.findViewById(R.id.outgoing_call_animation_circle).setBackgroundColor(palette.mPrimaryColor); getWindow().setStatusBarColor(palette.mSecondaryColor); } view.getViewTreeObserver().addOnPreDrawListener(new OnPreDrawListener() { @Override public boolean onPreDraw() { final ViewTreeObserver vto = view.getViewTreeObserver(); if (vto.isAlive()) { vto.removeOnPreDrawListener(this); } final Animator animator = getRevealAnimator(touchPoint); // Since this animator is a RenderNodeAnimator (native animator), add an arbitary // start delay to force the onAnimationStart callback to happen later on the UI // thread. Otherwise it would happen right away inside animator.start() animator.setStartDelay(5); animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { InCallPresenter.getInstance().onCircularRevealStarted(CircularRevealActivity.this); } @Override public void onAnimationEnd(Animator animation) { view.setClipToOutline(false); super.onAnimationEnd(animation); } }); animator.start(); return false; } }); }
From source file:net.kourlas.voipms_sms.activities.ConversationQuickReplyActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.conversation_quick_reply); database = Database.getInstance(getApplicationContext()); preferences = Preferences.getInstance(getApplicationContext()); contact = getIntent().getExtras().getString(getString(R.string.conversation_extra_contact)); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar);//from www. j ava 2s. c o m ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setHomeButtonEnabled(true); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayShowTitleEnabled(false); } NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); Integer notificationId = Notifications.getInstance(getApplicationContext()).getNotificationIds() .get(contact); if (notificationId != null) { manager.cancel(notificationId); } TextView replyToText = (TextView) findViewById(R.id.reply_to_edit_text); String contactName = Utils.getContactName(getApplicationContext(), contact); if (contactName == null) { replyToText.setText(getString(R.string.conversation_quick_reply_reply_to) + " " + Utils.getFormattedPhoneNumber(contact)); } else { replyToText.setText(getString(R.string.conversation_quick_reply_reply_to) + " " + contactName); } final EditText messageText = (EditText) findViewById(R.id.message_edit_text); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { messageText.setOutlineProvider(new ViewOutlineProvider() { @TargetApi(Build.VERSION_CODES.LOLLIPOP) @Override public void getOutline(View view, Outline outline) { outline.setRoundRect(0, 0, view.getWidth(), view.getHeight(), 15); } }); messageText.setClipToOutline(true); } messageText.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void afterTextChanged(Editable s) { ViewSwitcher viewSwitcher = (ViewSwitcher) findViewById(R.id.view_switcher); if (s.toString().equals("") && viewSwitcher.getDisplayedChild() == 1) { viewSwitcher.setDisplayedChild(0); } else if (viewSwitcher.getDisplayedChild() == 0) { viewSwitcher.setDisplayedChild(1); } } }); QuickContactBadge photo = (QuickContactBadge) findViewById(R.id.photo); Utils.applyCircularMask(photo); photo.assignContactFromPhone(Preferences.getInstance(getApplicationContext()).getDid(), true); Uri uri = Uri.withAppendedPath(ContactsContract.PhoneLookup.CONTENT_FILTER_URI, Uri.encode(Preferences.getInstance(getApplicationContext()).getDid())); Cursor cursor = getContentResolver().query(uri, new String[] { ContactsContract.PhoneLookup._ID, ContactsContract.PhoneLookup.PHOTO_THUMBNAIL_URI, ContactsContract.PhoneLookup.DISPLAY_NAME }, null, null, null); if (cursor.moveToFirst()) { String photoUri = cursor .getString(cursor.getColumnIndex(ContactsContract.Contacts.PHOTO_THUMBNAIL_URI)); if (photoUri != null) { photo.setImageURI(Uri.parse(photoUri)); } else { photo.setImageToDefault(); } } else { photo.setImageToDefault(); } cursor.close(); final ImageButton sendButton = (ImageButton) findViewById(R.id.send_button); Utils.applyCircularMask(sendButton); sendButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { preSendMessage(); } }); Button openAppButton = (Button) findViewById(R.id.open_app_button); openAppButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { finish(); Intent intent = new Intent(activity, ConversationActivity.class); intent.putExtra(getString(R.string.conversation_extra_contact), contact); TaskStackBuilder stackBuilder = TaskStackBuilder.create(getApplicationContext()); stackBuilder.addParentStack(ConversationActivity.class); stackBuilder.addNextIntent(intent); stackBuilder.startActivities(); } }); messageText.requestFocus(); }