当前位置: 首页>>代码示例>>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;未经允许,请勿转载。