Search in sources :

Example 1 with DefaultAccentColorStateList

use of carbon.drawable.DefaultAccentColorStateList in project Carbon by ZieIony.

the class FloatingActionButton method initFloatingActionButton.

private void initFloatingActionButton(AttributeSet attrs, int defStyleAttr) {
    AnimUtils.setupElevationAnimator(getStateAnimator(), this);
    TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.FloatingActionButton, defStyleAttr, R.style.carbon_FloatingActionButton);
    setCornerRadius(a.getDimension(R.styleable.FloatingActionButton_carbon_cornerRadius, -1));
    if (a.hasValue(R.styleable.FloatingActionButton_carbon_menu)) {
        int resId = a.getResourceId(R.styleable.FloatingActionButton_carbon_menu, 0);
        if (resId != 0)
            setMenu(resId);
    }
    TypedValue bg = new TypedValue();
    a.getValue(R.styleable.FloatingActionButton_android_background, bg);
    if (bg.type >= TypedValue.TYPE_FIRST_COLOR_INT && bg.type <= TypedValue.TYPE_LAST_COLOR_INT && bg.data == 0)
        setBackgroundDrawable(new ColorStateListDrawable(AnimatedColorStateList.fromList(new DefaultAccentColorStateList(getContext()), animation -> postInvalidate())));
    a.recycle();
}
Also used : DefaultAccentColorStateList(carbon.drawable.DefaultAccentColorStateList) Context(android.content.Context) R(carbon.R) ColorStateListDrawable(carbon.drawable.ColorStateListDrawable) TypedArray(android.content.res.TypedArray) MenuItem(android.view.MenuItem) ColorStateList(android.content.res.ColorStateList) AttributeSet(android.util.AttributeSet) TypedValue(android.util.TypedValue) Menu(android.view.Menu) AnimatedColorStateList(carbon.animation.AnimatedColorStateList) Build(android.os.Build) AnimUtils(carbon.animation.AnimUtils) TargetApi(android.annotation.TargetApi) TypedArray(android.content.res.TypedArray) ColorStateListDrawable(carbon.drawable.ColorStateListDrawable) DefaultAccentColorStateList(carbon.drawable.DefaultAccentColorStateList) TypedValue(android.util.TypedValue)

Aggregations

TargetApi (android.annotation.TargetApi)1 Context (android.content.Context)1 ColorStateList (android.content.res.ColorStateList)1 TypedArray (android.content.res.TypedArray)1 Build (android.os.Build)1 AttributeSet (android.util.AttributeSet)1 TypedValue (android.util.TypedValue)1 Menu (android.view.Menu)1 MenuItem (android.view.MenuItem)1 R (carbon.R)1 AnimUtils (carbon.animation.AnimUtils)1 AnimatedColorStateList (carbon.animation.AnimatedColorStateList)1 ColorStateListDrawable (carbon.drawable.ColorStateListDrawable)1 DefaultAccentColorStateList (carbon.drawable.DefaultAccentColorStateList)1