本文整理汇总了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);
}
示例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);
}
}
示例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);
}
}
示例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();
}
示例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);
}
示例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();
}
示例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);
}
示例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);
}