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();
}
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);
}
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());
}
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());
}
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);
}
Aggregations