use of android.graphics.drawable.StateListDrawable in project FloatingActionButton by makovkastar.
the class FloatingActionButton method updateBackground.
private void updateBackground() {
StateListDrawable drawable = new StateListDrawable();
drawable.addState(new int[] { android.R.attr.state_pressed }, createDrawable(mColorPressed));
drawable.addState(new int[] { -android.R.attr.state_enabled }, createDrawable(mColorDisabled));
drawable.addState(new int[] {}, createDrawable(mColorNormal));
setBackgroundCompat(drawable);
}
use of android.graphics.drawable.StateListDrawable in project fresco by facebook.
the class GenericDraweeHierarchyBuilder method setPressedStateOverlay.
/**
* Sets the overlay for pressed state.
*
* @param drawable for pressed state
* @return
*/
public GenericDraweeHierarchyBuilder setPressedStateOverlay(@Nullable Drawable drawable) {
if (drawable == null) {
mPressedStateOverlay = null;
} else {
StateListDrawable stateListDrawable = new StateListDrawable();
stateListDrawable.addState(new int[] { android.R.attr.state_pressed }, drawable);
mPressedStateOverlay = stateListDrawable;
}
return this;
}
use of android.graphics.drawable.StateListDrawable in project cardslib by gabrielemariotti.
the class NativeChangeValueCardFragment method initCards.
/**
* Inits the initial card
*/
private void initCards() {
card1 = new CardExample(getActivity(), "Header", "Title");
cardView1 = (CardViewNative) getActivity().findViewById(R.id.carddemo_card_changevalue_id);
cardView1.setCard(card1);
card2 = new CardExample2(getActivity(), "Header", "Title");
cardView2 = (CardViewNative) getActivity().findViewById(R.id.carddemo_card_changevalue_id2);
cardView2.setCard(card2);
card3 = new CardExample3(getActivity(), "Header", "Title");
cardView3 = (CardViewNative) getActivity().findViewById(R.id.carddemo_card_changevalue_id3);
cardView3.setCard(card3);
card4 = new ColorCard(getActivity());
card4.setTitle("A simple car");
cardView4 = (CardViewNative) 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 cardslib by gabrielemariotti.
the class NativeChangeValueCardFragment 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 fresco by facebook.
the class GenericDraweeHierarchyTest method testHierarchy_WithPressedStateOverlay.
@Test
public void testHierarchy_WithPressedStateOverlay() throws Exception {
GenericDraweeHierarchy dh = mBuilder.setOverlay(mOverlay2).setPressedStateOverlay(mOverlay1).build();
RootDrawable rootDrawable = (RootDrawable) dh.getTopLevelDrawable();
FadeDrawable fadeDrawable = (FadeDrawable) rootDrawable.getCurrent();
assertEquals(8, fadeDrawable.getNumberOfLayers());
assertSame(mOverlay2, fadeDrawable.getDrawable(6));
StateListDrawable stateListDrawable = (StateListDrawable) fadeDrawable.getDrawable(7);
assertNotNull(stateListDrawable);
}
Aggregations