List of usage examples for android.graphics.drawable ColorDrawable ColorDrawable
public ColorDrawable(@ColorInt int color)
From source file:com.android.launcher3.CellLayout.java
@Override protected void onDraw(Canvas canvas) { if (!mIsDragTarget) { return;// w w w . j a v a2 s . c o m } // When we're large, we are either drawn in a "hover" state (ie when dragging an item to // a neighboring page) or with just a normal background (if backgroundAlpha > 0.0f) // When we're small, we are either drawn normally or in the "accepts drops" state (during // a drag). However, we also drag the mini hover background *over* one of those two // backgrounds if (mBackgroundAlpha > 0.0f) { mBackground.draw(canvas); } final Paint paint = mDragOutlinePaint; for (int i = 0; i < mDragOutlines.length; i++) { final float alpha = mDragOutlineAlphas[i]; if (alpha > 0) { final Rect r = mDragOutlines[i]; mTempRect.set(r); Utilities.scaleRectAboutCenter(mTempRect, getChildrenScale()); final Bitmap b = (Bitmap) mDragOutlineAnims[i].getTag(); paint.setAlpha((int) (alpha + .5f)); canvas.drawBitmap(b, null, mTempRect, paint); } } if (DEBUG_VISUALIZE_OCCUPIED) { int[] pt = new int[2]; ColorDrawable cd = new ColorDrawable(Color.RED); cd.setBounds(0, 0, mCellWidth, mCellHeight); for (int i = 0; i < mCountX; i++) { for (int j = 0; j < mCountY; j++) { if (mOccupied[i][j]) { cellToPoint(i, j, pt); canvas.save(); canvas.translate(pt[0], pt[1]); cd.draw(canvas); canvas.restore(); } } } } int previewOffset = FolderRingAnimator.sPreviewSize; // The folder outer / inner ring image(s) DeviceProfile grid = mLauncher.getDeviceProfile(); for (int i = 0; i < mFolderOuterRings.size(); i++) { FolderRingAnimator fra = mFolderOuterRings.get(i); Drawable d; int width, height; cellToPoint(fra.mCellX, fra.mCellY, mTempLocation); View child = getChildAt(fra.mCellX, fra.mCellY); if (child != null) { int centerX = mTempLocation[0] + mCellWidth / 2; int centerY = mTempLocation[1] + previewOffset / 2 + child.getPaddingTop() + grid.folderBackgroundOffset; // Draw outer ring, if it exists if (FolderIcon.HAS_OUTER_RING) { d = FolderRingAnimator.sSharedOuterRingDrawable; width = (int) (fra.getOuterRingSize() * getChildrenScale()); height = width; canvas.save(); canvas.translate(centerX - width / 2, centerY - height / 2); d.setBounds(0, 0, width, height); d.draw(canvas); canvas.restore(); } // Draw inner ring d = FolderRingAnimator.sSharedInnerRingDrawable; width = (int) (fra.getInnerRingSize() * getChildrenScale()); height = width; canvas.save(); canvas.translate(centerX - width / 2, centerY - width / 2); d.setBounds(0, 0, width, height); d.draw(canvas); canvas.restore(); } } if (mFolderLeaveBehindCell[0] >= 0 && mFolderLeaveBehindCell[1] >= 0) { Drawable d = FolderIcon.sSharedFolderLeaveBehind; int width = d.getIntrinsicWidth(); int height = d.getIntrinsicHeight(); cellToPoint(mFolderLeaveBehindCell[0], mFolderLeaveBehindCell[1], mTempLocation); View child = getChildAt(mFolderLeaveBehindCell[0], mFolderLeaveBehindCell[1]); if (child != null) { int centerX = mTempLocation[0] + mCellWidth / 2; int centerY = mTempLocation[1] + previewOffset / 2 + child.getPaddingTop() + grid.folderBackgroundOffset; canvas.save(); canvas.translate(centerX - width / 2, centerY - width / 2); d.setBounds(0, 0, width, height); d.draw(canvas); canvas.restore(); } } }
From source file:com.bitants.wally.views.swipeclearlayout.SwipeClearLayout.java
private void animateCircle() { float currentScale = circle.getScaleX(); if (currentScale == 0.0f) { circle.setScaleX(1.0f);//from ww w. jav a2s.co m circle.setScaleY(1.0f); currentScale = 1.0f; } int currentPixelSize = (int) (circle.getHeight() * currentScale); if (currentPixelSize == 0) { return; } int width = getMeasuredWidth(); int height = getMeasuredHeight(); int hypotenuse = (int) Math.sqrt(Math.pow(width, 2) + Math.pow(height, 2)); float goalScale = (hypotenuse / currentPixelSize) * 2; circle.setAlpha(1.0f); circle.animate().scaleX(goalScale).scaleY(goalScale).setDuration(duration / 2) .setListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animator) { } @Override public void onAnimationEnd(Animator animator) { if (isRefreshing()) { getChildAt(0).setAlpha(0.0f); //list should be invisible until it stops refreshing } if (getChildAt(3) == null) { filledView = new View(getContext()); ColorDrawable colorDrawable = new ColorDrawable(circleColor); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { filledView.setBackground(colorDrawable); } else { filledView.setBackgroundDrawable(colorDrawable); } addView(filledView, 3); RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) filledView .getLayoutParams(); params.width = RelativeLayout.LayoutParams.MATCH_PARENT; params.height = RelativeLayout.LayoutParams.MATCH_PARENT; filledView.setLayoutParams(params); } filledView.setVisibility(VISIBLE); filledView.setAlpha(1.0f); filledView.animate().alpha(0.0f).setDuration(duration / 2) .setListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animator) { } @Override public void onAnimationEnd(Animator animator) { // removeViewAt(3); } @Override public void onAnimationCancel(Animator animator) { } @Override public void onAnimationRepeat(Animator animator) { } }).start(); circle.setScaleX(1.0f); circle.setScaleY(1.0f); circle.setAlpha(1.0f); circle.setTranslationY(-circle.getHeight()); } @Override public void onAnimationCancel(Animator animator) { } @Override public void onAnimationRepeat(Animator animator) { } }).start(); }
From source file:com.birdeye.MainActivity.java
@Override public boolean onOptionsItemSelected(@NonNull MenuItem item) { switch (item.getItemId()) { case R.id.logout: fullReset();/* ww w. j av a 2s. c o m*/ startActivity(LoginActivity.create(this)); finish(); return true; case R.id.About: final Dialog dialog2 = new Dialog(MainActivity.this); dialog2.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog2.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT)); dialog2.setContentView(R.layout.about); dialog2.setCancelable(false); dialog2.show(); return true; case R.id.ShareApp: Intent sharingIntent = new Intent(Intent.ACTION_SEND); sharingIntent.setType("text/html"); sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, Html.fromHtml( "<p>Hey, am using this really cool hashtag activated camera app. Get it here #birdeyecamera.</p>")); startActivity(Intent.createChooser(sharingIntent, "Share using")); return true; case R.id.Recommend: Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("BirdEyeCamera", "birdeyecamera@digitalbabi.es", null)); emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Feature Recommendation"); startActivity(Intent.createChooser(emailIntent, "Send email...")); return true; case R.id.rateApp: final Uri uri = Uri.parse("market://details?id=" + getApplicationContext().getPackageName()); final Intent rateAppIntent = new Intent(Intent.ACTION_VIEW, uri); if (getPackageManager().queryIntentActivities(rateAppIntent, 0).size() > 0) { startActivity(rateAppIntent); } else { /* handle your error case: the device has no way to handle market urls */ } return true; case R.id.RemoveAds: if (Globals.hasPaid) { Toast.makeText(MainActivity.this, "You already are in a premium account", Toast.LENGTH_SHORT) .show(); } else { removeAdsDialog(); } return true; default: return super.onOptionsItemSelected(item); } }
From source file:com.granita.tasks.EditTaskFragment.java
@SuppressLint("NewApi") private void updateColor(float percentage) { if (VERSION.SDK_INT >= 11) { if (mColorBar == null) { percentage = 1;/*from w w w . j a va 2s . c o m*/ } else { percentage = Math.max(0, Math.min(Float.isNaN(percentage) ? 0 : percentage, 1)); } int newColor = getBlendColor(mListColor, darkenColor(mListColor), (int) ((0.5 + 0.5 * percentage) * 255)); ActionBar actionBar = ((ActionBarActivity) getActivity()).getSupportActionBar(); actionBar.setBackgroundDrawable(new ColorDrawable(newColor)); // this is a workaround to ensure the new color is applied on all devices, some devices show a transparent ActionBar if we don't do that. actionBar.setDisplayShowTitleEnabled(false); actionBar.setDisplayShowTitleEnabled(true); if (VERSION.SDK_INT >= 21) { Window window = getActivity().getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.setStatusBarColor(mixColors(newColor, mListColor)); // window.setNavigationBarColor(mixColors(newColor, mListColor)); } } mTaskListBar.setBackgroundColor(mListColor); if (mColorBar != null) { mColorBar.setBackgroundColor(mListColor); } }
From source file:com.ccz.viewimages.displayingbitmaps.util.ImageWorker.java
private void setImageDrawable(ImageView imageView, Drawable drawable, Bitmap transbitmap) { if (mFadeInBitmap) { // Transition drawable with a transparent drawable and the final drawable final TransitionDrawable td = new TransitionDrawable(new Drawable[] { new ColorDrawable(mResources.getColor(android.R.color.transparent)), drawable }); // Set background to loading bitmap if (null != transbitmap) { imageView.setBackgroundDrawable(new BitmapDrawable(mResources, transbitmap)); }//from w w w.j av a2 s .com imageView.setImageDrawable(td); td.startTransition(FADE_IN_TIME); } else { imageView.setImageDrawable(drawable); } }
From source file:com.marlonjones.voidlauncher.CellLayout.java
@Override protected void onDraw(Canvas canvas) { if (!mIsDragTarget) { return;/*from www. ja va2 s.co m*/ } // When we're large, we are either drawn in a "hover" state (ie when dragging an item to // a neighboring page) or with just a normal background (if backgroundAlpha > 0.0f) // When we're small, we are either drawn normally or in the "accepts drops" state (during // a drag). However, we also drag the mini hover background *over* one of those two // backgrounds if (mBackgroundAlpha > 0.0f) { mBackground.draw(canvas); } final Paint paint = mDragOutlinePaint; for (int i = 0; i < mDragOutlines.length; i++) { final float alpha = mDragOutlineAlphas[i]; if (alpha > 0) { final Bitmap b = (Bitmap) mDragOutlineAnims[i].getTag(); paint.setAlpha((int) (alpha + .5f)); canvas.drawBitmap(b, null, mDragOutlines[i], paint); } } if (DEBUG_VISUALIZE_OCCUPIED) { int[] pt = new int[2]; ColorDrawable cd = new ColorDrawable(Color.RED); cd.setBounds(0, 0, mCellWidth, mCellHeight); for (int i = 0; i < mCountX; i++) { for (int j = 0; j < mCountY; j++) { if (mOccupied.cells[i][j]) { cellToPoint(i, j, pt); canvas.save(); canvas.translate(pt[0], pt[1]); cd.draw(canvas); canvas.restore(); } } } } for (int i = 0; i < mFolderBackgrounds.size(); i++) { FolderIcon.PreviewBackground bg = mFolderBackgrounds.get(i); cellToPoint(bg.delegateCellX, bg.delegateCellY, mTempLocation); canvas.save(); canvas.translate(mTempLocation[0], mTempLocation[1]); bg.drawBackground(canvas, mFolderBgPaint); if (!bg.isClipping) { bg.drawBackgroundStroke(canvas, mFolderBgPaint); } canvas.restore(); } if (mFolderLeaveBehind.delegateCellX >= 0 && mFolderLeaveBehind.delegateCellY >= 0) { cellToPoint(mFolderLeaveBehind.delegateCellX, mFolderLeaveBehind.delegateCellY, mTempLocation); canvas.save(); canvas.translate(mTempLocation[0], mTempLocation[1]); mFolderLeaveBehind.drawLeaveBehind(canvas, mFolderBgPaint); canvas.restore(); } }
From source file:com.amazon.android.contentbrowser.helper.AuthHelper.java
/** * Load powered by logo from preferences with Glide. * * @param context The context to use. * @param poweredByLogoImageView The image view to use. *//*w ww . jav a2 s. co m*/ public void loadPoweredByLogo(Context context, ImageView poweredByLogoImageView) { try { String mvpdUrl = Preferences.getString(PreferencesConstants.MVPD_LOGO_URL); if (poweredByLogoImageView == null || mvpdUrl.isEmpty()) { Log.d(TAG, "No MVPD image view or URL found."); return; } poweredByLogoImageView.setVisibility(View.INVISIBLE); RequestListener listener = new RequestListener<String, GlideDrawable>() { @Override public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) { poweredByLogoImageView.setVisibility(View.INVISIBLE); Log.e(TAG, "Get image with glide failed for powered by logo!!!", e); return false; } @Override public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) { poweredByLogoImageView.setVisibility(View.VISIBLE); return false; } }; GlideHelper.loadImageIntoView(poweredByLogoImageView, context, mvpdUrl, listener, android.R.color.transparent, new ColorDrawable(ContextCompat.getColor(context, android.R.color.transparent))); } catch (Exception e) { Log.e(TAG, "loadPoweredByLogo failed, activity may not include it.", e); } }
From source file:com.ijiaban.yinxiang.MainActivity.java
/** * Changes the color of the action bar and status bar * @param color ARGB Color to apply//from w w w .j a va 2 s . co m */ @SuppressLint("NewApi") private void setColor(int color) { View mainView = findViewById(R.id.rootView); if (mainView == null) { Log.e("MainActivity:setColor()", "WARNING: Did not find root view."); } else { mainView.setBackgroundColor(color); } /* Set the action bar colour to the average colour of the generated image and the status bar colour for Android Version >= 5.0 accordingly. */ try { getSupportActionBar().setBackgroundDrawable(new ColorDrawable(color)); } catch (NullPointerException nullError) { Log.e("MainActivity:generateImageTask()", nullError.toString()); } catch (NoSuchMethodError methodError) { Log.e("MainActivity:generateImageTask()", methodError.toString()); } Log.d("MainActivity:generateImageTask()", "Changing status bar & action bar colour."); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { // Get the window through a reference to the activity. Activity parent = (Activity) mContext; Window window = parent.getWindow(); // Set the status bar colour of this window. int statusColor = ColorUtilities.getDarkenedColor(color); window.setStatusBarColor(statusColor); } }
From source file:com.lemon.lime.MainActivity.java
private void gaymode() { getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor("#FF69B4"))); mWebView.setBackgroundColor(Color.parseColor("#FF69B4")); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { window.setNavigationBarColor(Color.parseColor("#FF69B4")); window.setStatusBarColor(Color.parseColor("#FF69B4")); }/*w w w . j a v a 2 s .co m*/ }
From source file:com.mobantica.DriverItRide.activities.ActivityProfile.java
private void openDialogSelectLanguange() { View lstGroupView = getLayoutInflater().inflate(R.layout.dailog_select_language, null); dialogSelectLangunage = new Dialog(this, R.style.MaterialDialogSheet); dialogSelectLangunage.setContentView(lstGroupView); dialogSelectLangunage.setCancelable(true); dialogSelectLangunage.getWindow().setGravity(Gravity.CENTER); dialogSelectLangunage.getWindow()/*from www . java 2s. c o m*/ .setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT)); btnSave = (Button) dialogSelectLangunage.findViewById(R.id.btnSave); btnSave.setOnClickListener(this); rdoEnglish = (RadioButton) dialogSelectLangunage.findViewById(R.id.rdoEnglish); rdoHindi = (RadioButton) dialogSelectLangunage.findViewById(R.id.rdoHindi); rdoMarathi = (RadioButton) dialogSelectLangunage.findViewById(R.id.rdoMarathi); getPreviousLanguageSelected(); rdoEnglish.setOnCheckedChangeListener(this); rdoHindi.setOnCheckedChangeListener(this); rdoMarathi.setOnCheckedChangeListener(this); dialogSelectLangunage.show(); }