当前位置: 首页>>代码示例>>Java>>正文


Java FloatEffect类代码示例

本文整理汇总了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);
}
 
开发者ID:gentxq,项目名称:Genius-Android,代码行数:65,代码来源:FloatActionButton.java


注:本文中的net.qiujuer.genius.ui.drawable.effect.FloatEffect类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。