本文整理汇总了Java中net.qiujuer.genius.ui.drawable.effect.FloatEffect类的典型用法代码示例。如果您正苦于以下问题:Java FloatEffect类的具体用法?Java FloatEffect怎么用?Java FloatEffect使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FloatEffect类属于net.qiujuer.genius.ui.drawable.effect包,在下文中一共展示了FloatEffect类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import net.qiujuer.genius.ui.drawable.effect.FloatEffect; //导入依赖的package包/类
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void init(AttributeSet attrs, int defStyleAttr, int defStyleRes) {
if (attrs == null)
return;
final Context context = getContext();
final Resources resource = getResources();
// Load attributes
final TypedArray a = context.obtainStyledAttributes(
attrs, R.styleable.FloatActionButton, defStyleAttr, defStyleRes);
ColorStateList bgColor = a.getColorStateList(R.styleable.FloatActionButton_gBackgroundColor);
int touchColor = a.getColor(R.styleable.FloatActionButton_gTouchColor, Ui.TOUCH_PRESS_COLOR);
a.recycle();
// Enable
boolean enable = Ui.isEnableAttr(context, attrs);
setEnabled(enable);
// BackgroundColor
if (bgColor == null) {
bgColor = resource.getColorStateList(R.color.g_default_float_action_bg);
}
// Background drawable
final float density = resource.getDisplayMetrics().density;
final int shadowYOffset = (int) (density * Ui.Y_OFFSET);
final int shadowXOffset = (int) (density * Ui.X_OFFSET);
final int maxShadowOffset = Math.max(shadowXOffset, shadowYOffset);
mShadowRadius = (int) (density * Ui.SHADOW_RADIUS);
mShadowRadius += maxShadowOffset;
ShapeDrawable background;
if (Ui.SUPPER_LOLLIPOP) {
background = new ShapeDrawable(new OvalShape());
//ViewCompat.setElevation(this, Ui.SHADOW_ELEVATION * density);
setElevation(Ui.SHADOW_ELEVATION * density);
} else {
OvalShape oval = new OvalShadowShape(mShadowRadius);
background = new ShapeDrawable(oval);
// We want set this LayerType type on Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB
setLayerType(LAYER_TYPE_SOFTWARE, background.getPaint());
background.getPaint().setShadowLayer(mShadowRadius - maxShadowOffset, shadowXOffset, shadowYOffset,
Ui.KEY_SHADOW_COLOR);
final int padding = mShadowRadius;
// set padding so the inner image sits correctly within the shadow.
setPadding(Math.max(padding, getPaddingLeft()),
Math.max(padding, getPaddingTop()),
Math.max(padding, getPaddingRight()),
Math.max(padding, getPaddingBottom()));
}
setBackgroundDrawable(background);
setBackgroundColor(bgColor);
// TouchDrawable
mTouchDrawable = new TouchEffectDrawable(new FloatEffect(), ColorStateList.valueOf(touchColor));
mTouchDrawable.setCallback(this);
mTouchDrawable.setPerformClicker(this);
}