Java Code Examples for android.widget.Button#getCompoundDrawables()
The following examples show how to use
android.widget.Button#getCompoundDrawables() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Utils.java From ProgressButton with Apache License 2.0 | 6 votes |
public static Matcher<View> withCompoundDrawable(final int resourceId) { return new BoundedMatcher<View, Button>(Button.class) { @Override public void describeTo(Description description) { description.appendText("has compound drawable resource " + resourceId); } @Override public boolean matchesSafely(Button textView) { for (Drawable drawable : textView.getCompoundDrawables()) { if (sameBitmap(textView.getContext(), drawable, resourceId)) { return true; } } return false; } }; }
Example 2
Source File: EmTintUtils.java From AndroidTint with Apache License 2.0 | 6 votes |
public static void setTint(@NonNull Button button, @ColorInt int color) { ColorStateList s1 = ColorStateList.valueOf(color); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { button.setCompoundDrawableTintList(s1); } else if (Build.VERSION.SDK_INT > Build.VERSION_CODES.GINGERBREAD_MR1) { Drawable drawable = DrawableCompat.wrap(button.getCompoundDrawables()[1]); button.setCompoundDrawablesWithIntrinsicBounds(null, drawable, null, null); DrawableCompat.setTintList(drawable, s1); } else { PorterDuff.Mode mode = PorterDuff.Mode.SRC_IN; if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.GINGERBREAD_MR1) { mode = PorterDuff.Mode.MULTIPLY; } if (button.getCompoundDrawables()[1] != null) button.getCompoundDrawables()[1].setColorFilter(color, mode); } }
Example 3
Source File: RoundButton.java From RoundButton with MIT License | 5 votes |
public ButtonProperty(Button button) { width = button.getWidth(); height = button.getHeight(); text = button.getText().toString(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { drawables = button.getCompoundDrawablesRelative(); } else { drawables = button.getCompoundDrawables(); } }
Example 4
Source File: DialogBase.java From microMathematics with GNU General Public License v3.0 | 5 votes |
protected void prepareButtonImage(Button b) { for (Drawable d : b.getCompoundDrawables()) { CompatUtils.setDrawableColorAttr(getContext(), d, b.isEnabled() ? R.attr.colorDialogContent : R.attr.colorDialogDisabledElement); } }
Example 5
Source File: AlarmDismissActivity.java From SuntimesWidget with GNU General Public License v3.0 | 5 votes |
private static void colorizeButtonCompoundDrawable(int color, @NonNull Button button) { Drawable[] drawables = button.getCompoundDrawables(); for (Drawable d : drawables) { if (d != null) { d.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); } } button.setCompoundDrawables(drawables[0], drawables[1], drawables[2], drawables[3]); }