當前位置: 首頁>>代碼示例>>Java>>正文


Java ClipDrawable類代碼示例

本文整理匯總了Java中android.graphics.drawable.ClipDrawable的典型用法代碼示例。如果您正苦於以下問題:Java ClipDrawable類的具體用法?Java ClipDrawable怎麽用?Java ClipDrawable使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ClipDrawable類屬於android.graphics.drawable包,在下文中一共展示了ClipDrawable類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: StrengthMeter

import android.graphics.drawable.ClipDrawable; //導入依賴的package包/類
public StrengthMeter(Context context, AttributeSet attrs) {
	super(context, attrs, android.R.attr.progressBarStyleHorizontal);
	bar = new ShapeDrawable();
	bar.getPaint().setColor(RED);
	ClipDrawable clip = new ClipDrawable(bar, LEFT, HORIZONTAL);
	ShapeDrawable background = new ShapeDrawable();
	Paint p = background.getPaint();
	p.setStyle(FILL);
	p.setColor(getResources().getColor(android.R.color.transparent));
	p.setStyle(STROKE);
	p.setStrokeWidth(1);
	p.setColor(BLACK);
	Drawable[] layers = new Drawable[] { clip, background };
	setProgressDrawable(new LayerDrawable(layers));
	setIndeterminate(false);
}
 
開發者ID:rafjordao,項目名稱:Nird2,代碼行數:17,代碼來源:StrengthMeter.java

示例2: onCreate

import android.graphics.drawable.ClipDrawable; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    findViewById(R.id.tv_transition).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            TransitionDrawable drawable = (TransitionDrawable) v.getBackground();
            drawable.startTransition(3000);
        }
    });

    ScaleDrawable scaleDrawable = (ScaleDrawable) findViewById(R.id.v_scale).getBackground();
    scaleDrawable.setLevel(10);      //lever默認為0,無法顯示。level範圍為0~10000。level越大,顯示的越大

    ClipDrawable clipDrawable = (ClipDrawable) findViewById(R.id.v_clip).getBackground();
    clipDrawable.setLevel(5000);

    View vCustom = findViewById(R.id.v_custom);
    CustomDrawable customDrawable = new CustomDrawable(getResources().getColor(R.color.colorAccent));
    vCustom.setBackground(customDrawable);
}
 
開發者ID:DysaniazzZ,項目名稱:ArtOfAndroid,代碼行數:24,代碼來源:MainActivity.java

示例3: initMaskBitmap

import android.graphics.drawable.ClipDrawable; //導入依賴的package包/類
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);
}
 
開發者ID:chiemy,項目名稱:LoadingImageView,代碼行數:22,代碼來源:LoadingImageView.java

示例4: setTargetOffsetTopAndBottom

import android.graphics.drawable.ClipDrawable; //導入依賴的package包/類
private void setTargetOffsetTopAndBottom(int offset) {
    circle.offsetTopAndBottom(offset);
    currentTargetOffsetTop = circle.getTop();
    int percent = (int) ((currentTargetOffsetTop / distanceToTriggerSync) * 100);
    if (onSwipeListener != null) {
        onSwipeListener.onSwipe(percent, currentTargetOffsetTop);
    }
    ViewCompat.setElevation(circle, percent);
    ImageView imageView = (ImageView) circle;
    ClipDrawable clipDrawable = (ClipDrawable) imageView.getDrawable();

    if (percent < 50) {
        clipDrawable.setLevel(0);
    } else {
        clipDrawable.setLevel((percent - 50) * 2 * 100);
    }
}
 
開發者ID:yeloapp,項目名稱:yelo-android,代碼行數:18,代碼來源:SwipeClearLayout.java

示例5: setProgressDrawable

import android.graphics.drawable.ClipDrawable; //導入依賴的package包/類
/**
 * 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);
}
 
開發者ID:Tombarr,項目名稱:Noyze,代碼行數:28,代碼來源:CmBatteryBar.java

示例6: ClipDrawableProgressBar

import android.graphics.drawable.ClipDrawable; //導入依賴的package包/類
/**
 * 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));
}
 
開發者ID:mogoweb,項目名稱:365browser,代碼行數:23,代碼來源:ClipDrawableProgressBar.java

示例7: assertEquals

import android.graphics.drawable.ClipDrawable; //導入依賴的package包/類
public static void assertEquals(ClipDrawable a,ClipDrawable b)
{
    assertEqualsDrawableWrapper(a, b);

    Rect ar = new Rect(); Rect br = new Rect();
    a.getPadding(ar); b.getPadding(br);
    assertEquals(ar, br);

    Drawable.ConstantState a_state = a.getConstantState();
    Drawable.ConstantState b_state = b.getConstantState();

    Class classClipState = TestUtil.resolveClass(ClipDrawable.class.getName() + "$ClipState");
    assertEquals((Integer) TestUtil.getField(a_state, classClipState, "mOrientation"), (Integer) TestUtil.getField(b_state, classClipState, "mOrientation"));
    assertEquals((Integer) TestUtil.getField(a_state, classClipState, "mGravity"), (Integer) TestUtil.getField(b_state, classClipState, "mGravity"));

    // android:drawable
    if (Build.VERSION.SDK_INT < TestUtil.MARSHMALLOW) // 23
    {
        assertEquals((Drawable) TestUtil.getField(a_state, classClipState, "mDrawable"), (Drawable) TestUtil.getField(b_state, classClipState, "mDrawable"));
    }
}
 
開發者ID:jmarranz,項目名稱:itsnat_droid,代碼行數:22,代碼來源:Assert.java

示例8: onWindowFocusChanged

import android.graphics.drawable.ClipDrawable; //導入依賴的package包/類
@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);
    }
}
 
開發者ID:singwhatiwanna,項目名稱:android-art-res,代碼行數:26,代碼來源:MainActivity.java

示例9: setShadow

import android.graphics.drawable.ClipDrawable; //導入依賴的package包/類
private void setShadow(int drawableId) {
    Drawable original = ContextCompat.getDrawable(TranSappApplication.getAppContext(), drawableId) ;
    Drawable shadow = getClone(original).mutate();
    toGrayScale(shadow);

    Drawable background = getClone(original).mutate();
    background.setColorFilter(
            ContextCompat.getColor(getContext(), R.color.background_white), PorterDuff.Mode.SRC_ATOP);

    Drawable drawableArray[]= new Drawable[]{background, shadow};
    LayerDrawable layerDraw = new LayerDrawable(drawableArray);


    clipDrawable = new ClipDrawable(layerDraw, Gravity.BOTTOM, ClipDrawable.VERTICAL);
    this.shadow.setImageDrawable(clipDrawable);
}
 
開發者ID:InspectorIncognito,項目名稱:androidApp,代碼行數:17,代碼來源:ReportView.java

示例10: RATINGBAR_PROGERSS_DRAWABLE

import android.graphics.drawable.ClipDrawable; //導入依賴的package包/類
/** RatingBar 星星 */
public static Drawable RATINGBAR_PROGERSS_DRAWABLE() {
    Drawable[] layers = new Drawable[3];
    Drawable darwable1 = getDrawable(IcomoonIcon.ICON_IC_STAR_NORMAL, NUMBER_3_INT,10,10);
    Drawable darwable2 = getDrawable(IcomoonIcon.ICON_IC_STAR_NORMAL, NUMBER_3_INT,10,10);
    Drawable darwable3 = getDrawable(IcomoonIcon.ICON_IC_STAR_SOLID, NUMBER_3_INT,10,10);
    
    
    layers[0] = darwable1;
    layers[1] = new ClipDrawable(darwable2, Gravity.LEFT, ClipDrawable.HORIZONTAL);
    layers[2] = new ClipDrawable(darwable3, Gravity.LEFT, ClipDrawable.HORIZONTAL);
    LayerDrawable drawable = new LayerDrawable(layers);
    drawable.setId(0, android.R.id.background);
    drawable.setId(1, android.R.id.secondaryProgress);
    drawable.setId(2, android.R.id.progress);
    return drawable;
}
 
開發者ID:cdkd321,項目名稱:pure,代碼行數:18,代碼來源:AppMaterial.java

示例11: buildRatingBarDrawables

import android.graphics.drawable.ClipDrawable; //導入依賴的package包/類
private Drawable buildRatingBarDrawables(Bitmap[] images) {
    final int[] requiredIds = { android.R.id.background, android.R.id.secondaryProgress, android.R.id.progress };
    final float[] roundedCorners = new float[] { 5, 5, 5, 5, 5, 5, 5, 5 };
    Drawable[] pieces = new Drawable[3];
    for (int i = 0; i < 3; i++) {

        ShapeDrawable sd = new ShapeDrawable(new RoundRectShape(roundedCorners, null, null));

        BitmapShader bitmapShader = new BitmapShader(images[i], Shader.TileMode.REPEAT, Shader.TileMode.CLAMP);
        sd.getPaint().setShader(bitmapShader);

        ClipDrawable cd = new ClipDrawable(sd, Gravity.LEFT, ClipDrawable.HORIZONTAL);
        if (i == 0) {
            pieces[i] = sd;
        } else {
            pieces[i] = cd;
        }
    }
    LayerDrawable ld = new LayerDrawable(pieces);
    for (int i = 0; i < 3; i++) {
        ld.setId(i, requiredIds[i]);
    }
    return ld;
}
 
開發者ID:cdkd321,項目名稱:pure,代碼行數:25,代碼來源:MaterialUtils.java

示例12: StrengthMeter

import android.graphics.drawable.ClipDrawable; //導入依賴的package包/類
public StrengthMeter(Context context) {
	super(context, null, android.R.attr.progressBarStyleHorizontal);
	bar = new ShapeDrawable();
	bar.getPaint().setColor(RED);
	ClipDrawable clip = new ClipDrawable(bar, LEFT, HORIZONTAL);
	ShapeDrawable background = new ShapeDrawable();
	Paint p = background.getPaint();
	p.setStyle(FILL);
	p.setColor(getResources().getColor(android.R.color.transparent));
	p.setStyle(STROKE);
	p.setStrokeWidth(1);
	p.setColor(BLACK);
	Drawable[] layers = new Drawable[] { clip, background };
	setProgressDrawable(new LayerDrawable(layers));
	setIndeterminate(false);
}
 
開發者ID:kiggundu,項目名稱:briar,代碼行數:17,代碼來源:StrengthMeter.java

示例13: positionStickyHeader

import android.graphics.drawable.ClipDrawable; //導入依賴的package包/類
void positionStickyHeader() {
    // sticky header
    final int top = mListHeader.getTop();
    final int stickyHeight = mStickyHeader.getMeasuredHeight();
    final int headerHeight = mListHeader.getMeasuredHeight();
    final int delta = headerHeight - stickyHeight;
    final int pos = delta + top;
    // reposition header
    mStickyHeader.setTranslationY(Math.max(pos,0));
    if (pos < 0 && !mIsStuck) {
        mIsStuck = true;
        makeSlideAnimator(5000, 10000, (ClipDrawable)mStickyHeader.getBackground()).start();
    } else if (pos > 0 && mIsStuck) {
        mIsStuck = false;
        makeSlideAnimator(10000, 5000, (ClipDrawable)mStickyHeader.getBackground()).start();
    }
}
 
開發者ID:OpenSilk,項目名稱:Orpheus,代碼行數:18,代碼來源:ProfilePortraitView.java

示例14: onScroll

import android.graphics.drawable.ClipDrawable; //導入依賴的package包/類
@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
    // logic here derived from http://antoine-merle.com/blog/2013/10/04/making-that-google-plus-profile-screen/
    if (visibleItemCount == 0) return;
    if (firstVisibleItem == 0 && mList.getChildCount() > 0) {
        // parallax
        mHeroContainer.setTranslationY(-mList.getChildAt(0).getTop() / 2);
    }
    // sticky header
    final int top = mListHeader.getTop();
    final int stickyHeight = mStickyHeader.getMeasuredHeight();
    final int headerHeight = mListHeader.getMeasuredHeight();
    final int delta = headerHeight - stickyHeight;
    final int pos = delta + top;
    // reposition header
    mStickyHeader.setTranslationY(Math.max(pos,0));
    if (pos < 0 && !mIsStuck) {
        mIsStuck = true;
        makeSlideAnimator(5000, 10000, (ClipDrawable)mStickyHeader.getBackground()).start();
    } else if (pos > 0 && mIsStuck) {
        mIsStuck = false;
        makeSlideAnimator(10000,5000, (ClipDrawable)mStickyHeader.getBackground()).start();
    }
}
 
開發者ID:OpenSilk,項目名稱:Orpheus,代碼行數:25,代碼來源:PlaylistPortraitView.java

示例15: applyProgressBarSettings

import android.graphics.drawable.ClipDrawable; //導入依賴的package包/類
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)
                        .strokeWidth(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);
    }
}
 
開發者ID:Mobideck,項目名稱:appdeck-android,代碼行數:20,代碼來源:DefaultHeaderTransformer.java


注:本文中的android.graphics.drawable.ClipDrawable類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。