Search in sources :

Example 6 with StateListDrawable

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);
}
Also used : StateListDrawable(android.graphics.drawable.StateListDrawable)

Example 7 with StateListDrawable

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;
}
Also used : StateListDrawable(android.graphics.drawable.StateListDrawable)

Example 8 with StateListDrawable

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);
}
Also used : StateListDrawable(android.graphics.drawable.StateListDrawable) ColorCard(it.gmariotti.cardslib.demo.cards.ColorCard)

Example 9 with StateListDrawable

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();
}
Also used : StateListDrawable(android.graphics.drawable.StateListDrawable)

Example 10 with StateListDrawable

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);
}
Also used : FadeDrawable(com.facebook.drawee.drawable.FadeDrawable) StateListDrawable(android.graphics.drawable.StateListDrawable) Test(org.junit.Test)

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