Search in sources :

Example 86 with StateListDrawable

use of android.graphics.drawable.StateListDrawable in project cardslib by gabrielemariotti.

the class ChangeValueCardFragment method changeCard4.

/**
     * Change background dinamically
     */
private void changeCard4() {
    StateListDrawable newDrawable = new StateListDrawable();
    newDrawable.addState(new int[] { android.R.attr.state_pressed }, getResources().getDrawable(R.drawable.pressed_background_card));
    newDrawable.addState(new int[] {}, getResources().getDrawable(R.drawable.demo_card_background_color2));
    card4.setBackgroundResource(newDrawable);
    //cardView4.refreshCard(card4);
    card4.notifyDataSetChanged();
}
Also used : StateListDrawable(android.graphics.drawable.StateListDrawable)

Example 87 with StateListDrawable

use of android.graphics.drawable.StateListDrawable in project cardslib by gabrielemariotti.

the class ChangeValueCardFragment method initCards.

/**
     * Inits the initial card
     */
private void initCards() {
    card1 = new CardExample(getActivity(), "Header", "Title");
    cardView1 = (CardView) getActivity().findViewById(R.id.carddemo_card_changevalue_id);
    cardView1.setCard(card1);
    card2 = new CardExample2(getActivity(), "Header", "Title");
    cardView2 = (CardView) getActivity().findViewById(R.id.carddemo_card_changevalue_id2);
    cardView2.setCard(card2);
    card3 = new CardExample3(getActivity(), "Header", "Title");
    cardView3 = (CardView) getActivity().findViewById(R.id.carddemo_card_changevalue_id3);
    cardView3.setCard(card3);
    card4 = new ColorCard(getActivity());
    card4.setTitle("A simple car");
    cardView4 = (CardView) getActivity().findViewById(R.id.carddemo_card_changevalue_id4);
    StateListDrawable initDrawable = new StateListDrawable();
    initDrawable.addState(new int[] { android.R.attr.state_pressed }, getResources().getDrawable(R.drawable.pressed_background_card));
    initDrawable.addState(new int[] {}, getResources().getDrawable(R.drawable.demo_card_background_color1));
    card4.setBackgroundResource(initDrawable);
    cardView4.setCard(card4);
}
Also used : StateListDrawable(android.graphics.drawable.StateListDrawable) ColorCard(it.gmariotti.cardslib.demo.cards.ColorCard)

Example 88 with StateListDrawable

use of android.graphics.drawable.StateListDrawable in project circular-progress-button by dmytrodanylyk.

the class CircularProgressButton method initCompleteStateDrawable.

private void initCompleteStateDrawable() {
    int colorPressed = getPressedColor(mCompleteColorState);
    StrokeGradientDrawable drawablePressed = createDrawable(colorPressed);
    mCompleteStateDrawable = new StateListDrawable();
    mCompleteStateDrawable.addState(new int[] { android.R.attr.state_pressed }, drawablePressed.getGradientDrawable());
    mCompleteStateDrawable.addState(StateSet.WILD_CARD, background.getGradientDrawable());
}
Also used : StateListDrawable(android.graphics.drawable.StateListDrawable) SuppressLint(android.annotation.SuppressLint)

Example 89 with StateListDrawable

use of android.graphics.drawable.StateListDrawable in project circular-progress-button by dmytrodanylyk.

the class CircularProgressButton method initIdleStateDrawable.

private void initIdleStateDrawable() {
    int colorNormal = getNormalColor(mIdleColorState);
    int colorPressed = getPressedColor(mIdleColorState);
    int colorFocused = getFocusedColor(mIdleColorState);
    int colorDisabled = getDisabledColor(mIdleColorState);
    if (background == null) {
        background = createDrawable(colorNormal);
    }
    StrokeGradientDrawable drawableDisabled = createDrawable(colorDisabled);
    StrokeGradientDrawable drawableFocused = createDrawable(colorFocused);
    StrokeGradientDrawable drawablePressed = createDrawable(colorPressed);
    mIdleStateDrawable = new StateListDrawable();
    mIdleStateDrawable.addState(new int[] { android.R.attr.state_pressed }, drawablePressed.getGradientDrawable());
    mIdleStateDrawable.addState(new int[] { android.R.attr.state_focused }, drawableFocused.getGradientDrawable());
    mIdleStateDrawable.addState(new int[] { -android.R.attr.state_enabled }, drawableDisabled.getGradientDrawable());
    mIdleStateDrawable.addState(StateSet.WILD_CARD, background.getGradientDrawable());
}
Also used : StateListDrawable(android.graphics.drawable.StateListDrawable) SuppressLint(android.annotation.SuppressLint)

Example 90 with StateListDrawable

use of android.graphics.drawable.StateListDrawable in project android-process-button by dmytrodanylyk.

the class FlatButton method init.

private void init(Context context, AttributeSet attrs) {
    mNormalDrawable = new StateListDrawable();
    if (attrs != null) {
        initAttributes(context, attrs);
    }
    mNormalText = getText().toString();
    setBackgroundCompat(mNormalDrawable);
}
Also used : StateListDrawable(android.graphics.drawable.StateListDrawable)

Aggregations

StateListDrawable (android.graphics.drawable.StateListDrawable)166 Drawable (android.graphics.drawable.Drawable)43 LayerDrawable (android.graphics.drawable.LayerDrawable)24 BitmapDrawable (android.graphics.drawable.BitmapDrawable)21 GradientDrawable (android.graphics.drawable.GradientDrawable)21 ColorDrawable (android.graphics.drawable.ColorDrawable)17 Bitmap (android.graphics.Bitmap)13 TextView (android.widget.TextView)12 ShapeDrawable (android.graphics.drawable.ShapeDrawable)11 View (android.view.View)11 AnimationDrawable (android.graphics.drawable.AnimationDrawable)9 ClipDrawable (android.graphics.drawable.ClipDrawable)9 SuppressLint (android.annotation.SuppressLint)8 ColorStateList (android.content.res.ColorStateList)8 Paint (android.graphics.Paint)8 RippleDrawable (android.graphics.drawable.RippleDrawable)7 TargetApi (android.annotation.TargetApi)6 TypedArray (android.content.res.TypedArray)6 TextPaint (android.text.TextPaint)5 Button (android.widget.Button)5