android.graphics.drawable.ClipDrawable Java Examples
The following examples show how to use
android.graphics.drawable.ClipDrawable.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DefaultHeaderTransformer.java From Klyph with MIT License | 6 votes |
private void applyProgressBarSettings() { if (mHeaderProgressBar != null) { final int strokeWidth = mHeaderProgressBar.getResources() .getDimensionPixelSize(R.dimen.ptr_progress_bar_stroke_width); mHeaderProgressBar.setIndeterminateDrawable( new SmoothProgressDrawable.Builder(mHeaderProgressBar.getContext()) .color(mProgressDrawableColor) .width(strokeWidth) .build()); ShapeDrawable shape = new ShapeDrawable(); shape.setShape(new RectShape()); shape.getPaint().setColor(mProgressDrawableColor); ClipDrawable clipDrawable = new ClipDrawable(shape, Gravity.CENTER, ClipDrawable.HORIZONTAL); mHeaderProgressBar.setProgressDrawable(clipDrawable); } }
Example #2
Source File: LoadingImageView.java From Loop with Apache License 2.0 | 6 votes |
private void initMaskBitmap(int maskColor) { Drawable drawable = getDrawable(); if(drawable == null){ return; } Bitmap bgd = ((BitmapDrawable) drawable).getBitmap(); imageWidth = drawable.getIntrinsicWidth(); imageHeight = drawable.getIntrinsicHeight(); Bitmap fg = Bitmap.createBitmap(imageWidth, imageHeight, Bitmap.Config.ARGB_8888); Canvas fgCanvas = new Canvas(fg); fgCanvas.drawColor(maskColor); Bitmap bitmap = combineImages(bgd, fg); maskDrawable = new BitmapDrawable(bitmap); clipDrawable = new ClipDrawable(maskDrawable, gravity, orientaion); //shader = new BitmapShader(bitmap, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP); //paint.setShader(shader); }
Example #3
Source File: CmBatteryBar.java From Noyze with Apache License 2.0 | 6 votes |
/** * Updates the {@link ShapeDrawable} which displays the * color of the bar across the screen. */ public void setProgressDrawable(Drawable mDrawable, int mNewColor) { if (mDrawable instanceof LayerDrawable && getProgressDrawable() instanceof LayerDrawable) { final LayerDrawable mDraw = (LayerDrawable) getProgressDrawable(); final ClipDrawable mShape = (ClipDrawable) mDraw.findDrawableByLayerId(android.R.id.progress); // Make sure we've got everything. if (mShape != null && mProgress != null && mProgress.getPaint() != null) { mProgress.getPaint().setColor(mNewColor); final Rect mBounds = mDraw.getBounds(); super.setProgressDrawable(mDraw); getProgressDrawable().setBounds(mBounds); return; } } super.setProgressDrawable(mDrawable); }
Example #4
Source File: ClipDrawableProgressBar.java From 365browser with Apache License 2.0 | 6 votes |
/** * Create the progress bar with a custom height. * @param context An Android context. * @param height The height in px of the progress bar. */ public ClipDrawableProgressBar(Context context, int height) { super(context); mDesiredVisibility = getVisibility(); int foregroundColor = ApiCompatibilityUtils.getColor(getResources(), R.color.progress_bar_foreground); mBackgroundColor = ApiCompatibilityUtils.getColor(getResources(), R.color.progress_bar_background); mForegroundDrawable = new ColorDrawable(foregroundColor); setImageDrawable( new ClipDrawable(mForegroundDrawable, Gravity.START, ClipDrawable.HORIZONTAL)); setBackgroundColor(mBackgroundColor); setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, height)); }
Example #5
Source File: MainActivity.java From android-art-res with Apache License 2.0 | 6 votes |
@Override public void onWindowFocusChanged(boolean hasFocus) { super.onWindowFocusChanged(hasFocus); if (hasFocus) { // test transition View v = findViewById(R.id.test_transition); TransitionDrawable drawable = (TransitionDrawable) v.getBackground(); drawable.startTransition(1000); // test scale View testScale = findViewById(R.id.test_scale); ScaleDrawable testScaleDrawable = (ScaleDrawable) testScale.getBackground(); testScaleDrawable.setLevel(10); // test clip ImageView testClip = (ImageView) findViewById(R.id.test_clip); ClipDrawable testClipDrawable = (ClipDrawable) testClip.getDrawable(); testClipDrawable.setLevel(8000); // test custom drawable View testCustomDrawable = findViewById(R.id.test_custom_drawable); CustomDrawable customDrawable = new CustomDrawable(Color.parseColor("#0ac39e")); testCustomDrawable.setBackgroundDrawable(customDrawable); } }
Example #6
Source File: LoadingImageView.java From LoadingImageView with MIT License | 6 votes |
private void initMaskBitmap(int maskColor) { Drawable drawable = getDrawable(); if(drawable == null){ return; } Bitmap bgd = ((BitmapDrawable) drawable).getBitmap(); imageWidth = drawable.getIntrinsicWidth(); imageHeight = drawable.getIntrinsicHeight(); Bitmap fg = Bitmap.createBitmap(imageWidth, imageHeight, Bitmap.Config.ARGB_8888); Canvas fgCanvas = new Canvas(fg); fgCanvas.drawColor(maskColor); Bitmap bitmap = combineImages(bgd, fg); maskDrawable = new BitmapDrawable(bitmap); clipDrawable = new ClipDrawable(maskDrawable, gravity, orientaion); //shader = new BitmapShader(bitmap, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP); //paint.setShader(shader); }
Example #7
Source File: CmBatteryBar.java From Noyze with Apache License 2.0 | 6 votes |
/** * Updates the {@link ShapeDrawable} which displays the * color of the bar across the screen. */ public void setProgressDrawable(Drawable mDrawable, int mNewColor) { if (mDrawable instanceof LayerDrawable && getProgressDrawable() instanceof LayerDrawable) { final LayerDrawable mDraw = (LayerDrawable) getProgressDrawable(); final ClipDrawable mShape = (ClipDrawable) mDraw.findDrawableByLayerId(android.R.id.progress); // Make sure we've got everything. if (mShape != null && mProgress != null && mProgress.getPaint() != null) { mProgress.getPaint().setColor(mNewColor); final Rect mBounds = mDraw.getBounds(); super.setProgressDrawable(mDraw); getProgressDrawable().setBounds(mBounds); return; } } super.setProgressDrawable(mDrawable); }
Example #8
Source File: VoiceSearchWidget.java From FirefoxReality with Mozilla Public License 2.0 | 6 votes |
public void updateUI() { removeAllViews(); LayoutInflater inflater = LayoutInflater.from(getContext()); // Inflate this data binding layout mBinding = DataBindingUtil.inflate(inflater, R.layout.voice_search_dialog, this, true); mBinding.setLifecycleOwner((VRBrowserActivity)getContext()); Drawable mVoiceInputBackgroundDrawable = getResources().getDrawable(R.drawable.ic_voice_search_volume_input_black, getContext().getTheme()); mVoiceInputClipDrawable = new ClipDrawable(getContext().getDrawable(R.drawable.ic_voice_search_volume_input_clip), Gravity.START, ClipDrawable.HORIZONTAL); Drawable[] layers = new Drawable[] {mVoiceInputBackgroundDrawable, mVoiceInputClipDrawable }; mBinding.voiceSearchAnimationListening.setImageDrawable(new LayerDrawable(layers)); mVoiceInputClipDrawable.setLevel(0); mBinding.closeButton.setOnClickListener(view -> hide(KEEP_WIDGET)); }
Example #9
Source File: DefaultHeaderTransformer.java From KlyphMessenger with MIT License | 6 votes |
private void applyProgressBarSettings() { if (mHeaderProgressBar != null) { final int strokeWidth = mHeaderProgressBar.getResources() .getDimensionPixelSize(R.dimen.ptr_progress_bar_stroke_width); mHeaderProgressBar.setIndeterminateDrawable( new SmoothProgressDrawable.Builder(mHeaderProgressBar.getContext()) .color(mProgressDrawableColor) .width(strokeWidth) .build()); ShapeDrawable shape = new ShapeDrawable(); shape.setShape(new RectShape()); shape.getPaint().setColor(mProgressDrawableColor); ClipDrawable clipDrawable = new ClipDrawable(shape, Gravity.CENTER, ClipDrawable.HORIZONTAL); mHeaderProgressBar.setProgressDrawable(clipDrawable); } }
Example #10
Source File: DefaultHeaderTransformer.java From Bitocle with Apache License 2.0 | 5 votes |
private void applyProgressBarSettings() { if (mHeaderProgressBar != null) { ShapeDrawable shape = new ShapeDrawable(); shape.setShape(new RectShape()); shape.getPaint().setColor(mProgressDrawableColor); ClipDrawable clipDrawable = new ClipDrawable(shape, Gravity.CENTER, ClipDrawable.HORIZONTAL); mHeaderProgressBar.setProgressDrawable(clipDrawable); } }
Example #11
Source File: DrawableParser.java From Folivora with Apache License 2.0 | 5 votes |
@Override public Drawable parse(ParseRequest request) { final Context ctx = request.context(); final AttributeSet attrs = request.attrs(); TypedArray a = ctx.obtainStyledAttributes(attrs, R.styleable.Folivora_Clip); final Drawable child = getDrawable(ctx, a, attrs, R.styleable.Folivora_Clip_clipDrawable); final int clipGravity = a.getInt(R.styleable.Folivora_Clip_clipGravity, Gravity.START); final int clipOrientation = a.getInt(R.styleable.Folivora_Clip_clipOrientation, ClipDrawable.HORIZONTAL); ClipDrawable cd = new ClipDrawable(child, clipGravity, clipOrientation); cd.setLevel(a.getInt(R.styleable.Folivora_Clip_clipLevel, 10000/*no clip*/)); a.recycle(); return cd; }
Example #12
Source File: TestShellToolbar.java From android-chromium with BSD 2-Clause "Simplified" License | 5 votes |
@Override protected void onFinishInflate() { super.onFinishInflate(); mProgressDrawable = (ClipDrawable) findViewById(R.id.toolbar).getBackground(); initializeUrlField(); initializeNavigationButtons(); initializeMenuButton(); }
Example #13
Source File: Shell.java From android-chromium with BSD 2-Clause "Simplified" License | 5 votes |
@Override protected void onFinishInflate() { super.onFinishInflate(); mProgressDrawable = (ClipDrawable) findViewById(R.id.toolbar).getBackground(); initializeUrlField(); initializeNavigationButtons(); }
Example #14
Source File: NumberProgressBar.java From Android_Skin_2.0 with Apache License 2.0 | 5 votes |
private Drawable tileifyProgressDrawable(Drawable wrapped) { if (wrapped instanceof LayerDrawable) { LayerDrawable drawable = (LayerDrawable) wrapped; final int N = drawable.getNumberOfLayers(); Drawable[] outDrawables = new Drawable[N]; for (int i = 0; i < N; i++) { final int id = drawable.getId(i); Drawable childDrawable = drawable.getDrawable(i); if (id == android.R.id.background) { outDrawables[i] = new NumberBGDrawable(childDrawable); } else if (id == android.R.id.progress) { if (childDrawable instanceof ScaleDrawable) { outDrawables[i] = tileifyScaleDrawable((ScaleDrawable) childDrawable); } else if (childDrawable instanceof ClipDrawable) { outDrawables[i] = tileifyClipDrawable((ClipDrawable) childDrawable); } else { outDrawables[i] = childDrawable; } } else { outDrawables[i] = childDrawable; } } LayerDrawable newDrawable = new NumberLayerDrawable(outDrawables); return newDrawable; } return wrapped; }
Example #15
Source File: TestShellToolbar.java From android-chromium with BSD 2-Clause "Simplified" License | 5 votes |
@Override protected void onFinishInflate() { super.onFinishInflate(); mProgressDrawable = (ClipDrawable) findViewById(R.id.toolbar).getBackground(); initializeUrlField(); initializeNavigationButtons(); initializeMenuButton(); }
Example #16
Source File: ThreadViewFragment.java From something.apk with MIT License | 5 votes |
private void updateHeaderState(){ ShapeDrawable shape = new ShapeDrawable(); shape.setShape(new RectShape()); shape.getPaint().setColor(page < maxPage ? nextPageColor : refreshColor); ClipDrawable clipDrawable = new ClipDrawable(shape, Gravity.CENTER, ClipDrawable.HORIZONTAL); pfbProgressbar.setProgressDrawable(clipDrawable); pfbTitle.setText(page < maxPage ? R.string.pull_bottom_nextpage : R.string.pull_to_refresh_pull_label); }
Example #17
Source File: DefaultHeaderTransformer.java From Bitocle with Apache License 2.0 | 5 votes |
private void applyProgressBarSettings() { if (mHeaderProgressBar != null) { ShapeDrawable shape = new ShapeDrawable(); shape.setShape(new RectShape()); shape.getPaint().setColor(mProgressDrawableColor); ClipDrawable clipDrawable = new ClipDrawable(shape, Gravity.CENTER, ClipDrawable.HORIZONTAL); mHeaderProgressBar.setProgressDrawable(clipDrawable); } }
Example #18
Source File: DefaultHeaderTransformer.java From Bitocle with Apache License 2.0 | 5 votes |
private void applyProgressBarSettings() { if (mHeaderProgressBar != null) { ShapeDrawable shape = new ShapeDrawable(); shape.setShape(new RectShape()); shape.getPaint().setColor(mProgressDrawableColor); ClipDrawable clipDrawable = new ClipDrawable(shape, Gravity.CENTER, ClipDrawable.HORIZONTAL); mHeaderProgressBar.setProgressDrawable(clipDrawable); } }
Example #19
Source File: AltitudeFragment.java From JayPS-AndroidApp with MIT License | 5 votes |
private void setGPSStatus(float accuracy) { String gpsStatus = ""; int level = 0; if (accuracy == 0) { gpsStatus = getString(R.string.altitude_status_disable); level = 0; } else if (accuracy <= 4) { gpsStatus = getString(R.string.altitude_status_excellent); level = 10000; } else if (accuracy <= 6) { gpsStatus = getString(R.string.altitude_status_good); level = 7200; } else if (accuracy <= 10) { gpsStatus = getString(R.string.altitude_status_medium); level = 5000; } else { gpsStatus = getString(R.string.altitude_status_poor); level = 2500; } TextView altitudeStatus = (TextView)getActivity().findViewById(R.id.altitude_status_value); altitudeStatus.setText(gpsStatus); // mask a part of the image (orientation horizontal, gravity left, 0 to 10000) ImageView img = (ImageView) getActivity().findViewById(R.id.altitude_graph); ClipDrawable mImageDrawable = (ClipDrawable) img.getDrawable(); mImageDrawable.setLevel(level); }
Example #20
Source File: Shell.java From android-chromium with BSD 2-Clause "Simplified" License | 5 votes |
@Override protected void onFinishInflate() { super.onFinishInflate(); mProgressDrawable = (ClipDrawable) findViewById(R.id.toolbar).getBackground(); initializeUrlField(); initializeNavigationButtons(); }
Example #21
Source File: RefreshNowProgressIndicator.java From RefreshNow with Apache License 2.0 | 5 votes |
public IndicatorConfig build() { final LineDrawable line = new LineDrawable(); line.setColor(progressColor); line.setStrokeWidth(progressStrokeWidth); final ClipDrawable progressDrawable = new ClipDrawable(line, Gravity.CENTER_VERTICAL, ClipDrawable.HORIZONTAL); return new IndicatorConfig(changeProgressDrawable ? progressDrawable : null, changeIndeterminateDrawable ? indeterminateDrawableBuilder.build() : null); }
Example #22
Source File: ProgressBarWrapper.java From Man-Man with GNU General Public License v3.0 | 5 votes |
private ProgressBar createProgressBar() { ProgressBar pb = (ProgressBar) View.inflate(mActivity, R.layout.actionbar_progressbar, null); ShapeDrawable shape = new ShapeDrawable(); shape.setShape(new RectShape()); shape.getPaint().setColor(Color.parseColor("#FF33B5E5")); ClipDrawable clipDrawable = new ClipDrawable(shape, Gravity.CENTER, ClipDrawable.HORIZONTAL); pb.setProgressDrawable(clipDrawable); return pb; }
Example #23
Source File: ProgressBarParser.java From proteus with Apache License 2.0 | 5 votes |
Drawable getLayerDrawable(int progress, int background) { ShapeDrawable shape = new ShapeDrawable(); shape.getPaint().setStyle(Paint.Style.FILL); shape.getPaint().setColor(background); ShapeDrawable shapeD = new ShapeDrawable(); shapeD.getPaint().setStyle(Paint.Style.FILL); shapeD.getPaint().setColor(progress); ClipDrawable clipDrawable = new ClipDrawable(shapeD, Gravity.LEFT, ClipDrawable.HORIZONTAL); return new LayerDrawable(new Drawable[]{shape, clipDrawable}); }
Example #24
Source File: FixedRatingBar.java From proteus with Apache License 2.0 | 5 votes |
/** * Taken from AOSP !! * Converts a drawable to a tiled version of itself. It will recursively * traverse layer and state list drawables. */ public Drawable getTiledDrawable(Drawable drawable, boolean clip) { if (drawable instanceof LayerDrawable) { LayerDrawable background = (LayerDrawable) drawable; final int N = background.getNumberOfLayers(); Drawable[] outDrawables = new Drawable[N]; for (int i = 0; i < N; i++) { int id = background.getId(i); outDrawables[i] = getTiledDrawable(background.getDrawable(i), (id == android.R.id.progress || id == android.R.id.secondaryProgress)); } LayerDrawable newBg = new LayerDrawable(outDrawables); for (int i = 0; i < N; i++) { newBg.setId(i, background.getId(i)); } return newBg; } else if (drawable instanceof BitmapDrawable) { final Bitmap tileBitmap = ((BitmapDrawable) drawable).getBitmap(); if (sampleTile == null) { sampleTile = tileBitmap; } final ShapeDrawable shapeDrawable = new ShapeDrawable(getDrawableShape()); final BitmapShader bitmapShader = new BitmapShader(tileBitmap, Shader.TileMode.REPEAT, Shader.TileMode.CLAMP); shapeDrawable.getPaint().setShader(bitmapShader); return (clip) ? new ClipDrawable(shapeDrawable, Gravity.LEFT, ClipDrawable.HORIZONTAL) : shapeDrawable; } return drawable; }
Example #25
Source File: FontProgressDrawable.java From FontDrawable with Apache License 2.0 | 5 votes |
private Drawable[] createDrawables(Bitmap[] bitmaps) { Drawable[] pieces = new Drawable[bitmaps.length]; for (int i = 0; i < bitmaps.length; i++) { BitmapDrawable bitmapDrawable = new BitmapDrawable(context.getResources(), bitmaps[i]); bitmapDrawable.setTileModeXY(Shader.TileMode.REPEAT, Shader.TileMode.CLAMP); if (i == 0) { pieces[i] = bitmapDrawable; } else { pieces[i] = new ClipDrawable(bitmapDrawable, Gravity.LEFT, ClipDrawable.HORIZONTAL); } } return pieces; }
Example #26
Source File: MyWebView.java From DoraemonKit with Apache License 2.0 | 5 votes |
private void addProgressView() { this.mProgressBar = new ProgressBar(this.getContext(), null, android.R.attr.progressBarStyleHorizontal); this.mProgressBar.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, 10, 0, 0)); Integer progressBarColor = getResources().getColor(R.color.dk_color_55A8FD); ClipDrawable d = new ClipDrawable(new ColorDrawable(progressBarColor), Gravity.LEFT, ClipDrawable.HORIZONTAL); this.mProgressBar.setProgressDrawable(d); this.mProgressBar.setVisibility(GONE); this.addView(this.mProgressBar); }
Example #27
Source File: PartialView.java From SimpleRatingBar with MIT License | 5 votes |
public void setFilledDrawable(@NonNull Drawable drawable) { if (drawable.getConstantState() == null) { return; } ClipDrawable clipDrawable = new ClipDrawable(drawable.getConstantState().newDrawable(), Gravity.START, ClipDrawable.HORIZONTAL); mFilledView.setImageDrawable(clipDrawable); }
Example #28
Source File: PartialView.java From SimpleRatingBar with MIT License | 5 votes |
public void setEmptyDrawable(@NonNull Drawable drawable) { if (drawable.getConstantState() == null) { return; } ClipDrawable clipDrawable = new ClipDrawable(drawable.getConstantState().newDrawable(), Gravity.END, ClipDrawable.HORIZONTAL); mEmptyView.setImageDrawable(clipDrawable); }
Example #29
Source File: ZProgressBar.java From AccountBook with GNU General Public License v3.0 | 5 votes |
private void createDrawable(){ Drawable[] layers = new Drawable[2]; Drawable background = makeBackground(); Drawable progress = makeProgress(); ClipDrawable clip = new ClipDrawable(progress , Gravity.LEFT, ClipDrawable.HORIZONTAL); layers[0] = background; layers[1] = clip; LayerDrawable layer = new LayerDrawable(layers); layer.setId(0, android.R.id.background); layer.setId(1, android.R.id.progress); setProgressDrawable(layer); }
Example #30
Source File: LoadingImageView.java From Loop with Apache License 2.0 | 5 votes |
/** * 设置方向 * @param orientation {@link MaskOrientation} */ public void setMaskOrientation(int orientation){ switch (orientation){ case MaskOrientation.LeftToRight: gravity = Gravity.LEFT; orientaion = ClipDrawable.HORIZONTAL; break; case MaskOrientation.RightToLeft: gravity = Gravity.RIGHT; orientaion = ClipDrawable.HORIZONTAL; break; case MaskOrientation.TopToBottom: gravity = Gravity.TOP; orientaion = ClipDrawable.VERTICAL; break; case MaskOrientation.BottomToTop: default: gravity = Gravity.BOTTOM; orientaion = ClipDrawable.VERTICAL; break; } if(maskDrawable == null){ return; } clipDrawable = new ClipDrawable(maskDrawable, gravity, orientaion); initAnim(); }