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


Java ClipDrawable.setLevel方法代碼示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: refreshDrawable

import android.graphics.drawable.ClipDrawable; //導入方法依賴的package包/類
protected void refreshDrawable(final Drawable drawable) {
	mDrawable = drawable;
	if (mDrawable == null) {
		mDrawable = new ColorDrawable(mColor);
	}
	int gravity = GRAVITY_FILL_VERTICAL | GRAVITY_LEFT;
	int orientation = ClipDrawable.HORIZONTAL;
	switch (mRotation) {
	case 90:
		gravity = GRAVITY_FILL_HORIZONTAL | GRAVITY_BOTTOM;
		orientation = ClipDrawable.VERTICAL;
		break;
	case 180:
		gravity = GRAVITY_FILL_VERTICAL | GRAVITY_RIGHT;
		orientation = ClipDrawable.HORIZONTAL;
		break;
	case 270:
		gravity = GRAVITY_FILL_HORIZONTAL | GRAVITY_TOP;
		orientation = ClipDrawable.VERTICAL;
		break;
	}
	mClipDrawable = new ClipDrawable(mDrawable, gravity, orientation);
	final Rect outRect = new Rect();
	getDrawingRect(outRect);
	mClipDrawable.setBounds(outRect);
	mClipDrawable.setLevel((int)(mProgress * mScale) + mMin);
	postInvalidate();
}
 
開發者ID:saki4510t,項目名稱:libcommon,代碼行數:29,代碼來源:ProgressView.java

示例5: setupStickyHeader

import android.graphics.drawable.ClipDrawable; //導入方法依賴的package包/類
void setupStickyHeader() {
    ClipDrawable d = new ClipDrawable(
            new ColorDrawable(ThemeUtils.getColorPrimary(getContext())),
            Gravity.BOTTOM, ClipDrawable.VERTICAL
    );
    d.setLevel(mIsStuck ? 10000 : 5000);
    mStickyHeader.setBackgroundDrawable(d);
}
 
開發者ID:OpenSilk,項目名稱:Orpheus,代碼行數:9,代碼來源:ProfilePortraitView.java

示例6: onCreate

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

    lastts = System.nanoTime();

    sm = (SensorManager) getSystemService(SENSOR_SERVICE);
    s = sm.getDefaultSensor(s.TYPE_ACCELEROMETER);

    tv = (TextView) this.findViewById(R.id.maintext);

    fal = new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            fuckall();
            return false;
        }
    };

    ivPlungerBox = (ImageView) this.findViewById(R.id.plunger_box);
    ivPlungerBox.setOnLongClickListener(fal);
    ivPlungerPlunger = (ImageView) this.findViewById(R.id.plunger_plunger);
    ivCharge = (ImageView) this.findViewById(R.id.charge_lvl_filled);

    ivPlungerBox.setImageResource(R.drawable.plunger_box);
    ivPlungerPlunger.setImageResource(R.drawable.plunger_plunger);// 150 px descent
    cfill = (ClipDrawable) ivCharge.getDrawable();
    cfill.setLevel(725);

    btn = (Button) this.findViewById(R.id.mainbtn);
    btn.setEnabled(false);

    cli = new AsyncHttpClient();
}
 
開發者ID:TobbenTM,項目名稱:RPi-LaunchControl,代碼行數:36,代碼來源:MainActivity.java

示例7: setGPSStatus

import android.graphics.drawable.ClipDrawable; //導入方法依賴的package包/類
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);
}
 
開發者ID:team-mount-ventoux,項目名稱:JayPS-AndroidApp,代碼行數:29,代碼來源:AltitudeFragment.java

示例8: ColorDialog

import android.graphics.drawable.ClipDrawable; //導入方法依賴的package包/類
public ColorDialog(Context context, boolean useAlpha, Object tag, int color, OnClickListener listener, int iconId) {
	super(context);
	mUseAlpha = useAlpha;
	mTag = tag;
	mListener = listener;

	Resources res = context.getResources();
	setTitle(res.getText(R.string.colorDialogTitle));
	setButton(BUTTON_POSITIVE, res.getText(android.R.string.ok), this);
	setButton(BUTTON_NEGATIVE, res.getText(android.R.string.cancel), this);
	View root = LayoutInflater.from(context).inflate(R.layout.color_picker, null);
	setView(root);
	
	View preview = root.findViewById(R.id.preview);
	mPreviewDrawable = new GradientDrawable();
	// 2 pix more than color_picker_frame's radius
	//mPreviewDrawable.setCornerRadius(7);
	Drawable[] layers;
	if (useAlpha) {
		mIcon = new IconPreviewDrawable(getContext().getResources(), iconId);
		ClipDrawable topClip = new ClipDrawable(mPreviewDrawable, Gravity.TOP, ClipDrawable.VERTICAL);
		topClip.setLevel(5000);
		layers = new Drawable[] {
				topClip,
				mIcon,
				res.getDrawable(R.drawable.color_picker_frame),
		};
	} else {
		layers = new Drawable[] {
				mPreviewDrawable,
				res.getDrawable(R.drawable.color_picker_frame),
		};
	}
	preview.setBackgroundDrawable(new LayerDrawable(layers));
	
	mHue = (SeekBar) root.findViewById(R.id.hue);
	mSaturation = (SeekBar) root.findViewById(R.id.saturation);
	mValue = (SeekBar) root.findViewById(R.id.value);
	mAlpha = (SeekBar) root.findViewById(R.id.alpha);
	
	mColor = color;
	float[] hsv = new float[3];
	Color.colorToHSV(color, hsv);
	int h = (int) (hsv[0] * mHue.getMax() / 360);
	int s = (int) (hsv[1] * mSaturation.getMax());
	int v = (int) (hsv[2] * mValue.getMax());
	setupSeekBar(mHue, R.string.colorHue, h, res);
	setupSeekBar(mSaturation, R.string.colorSaturation, s, res);
	setupSeekBar(mValue, R.string.colorValue, v, res);
	if (useAlpha) {
		int a = Color.alpha(color) * mAlpha.getMax() / 255;
		setupSeekBar(mAlpha, R.string.colorAlpha, a, res);
	} else {
		mAlpha.setVisibility(View.GONE);
	}
	
	updatePreview(color);
}
 
開發者ID:gskbyte,項目名稱:kora,代碼行數:59,代碼來源:ColorDialog.java


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