android.widget.Button#getCompoundDrawables ( )源码实例Demo

下面列出了android.widget.Button#getCompoundDrawables ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: ProgressButton   文件: Utils.java
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;
        }
    };
}
 
源代码2 项目: AndroidTint   文件: EmTintUtils.java
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);
    }
}
 
源代码3 项目: RoundButton   文件: RoundButton.java
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();
    }
}
 
源代码4 项目: microMathematics   文件: DialogBase.java
protected void prepareButtonImage(Button b)
{
    for (Drawable d : b.getCompoundDrawables())
    {
        CompatUtils.setDrawableColorAttr(getContext(), d,
                b.isEnabled() ? R.attr.colorDialogContent : R.attr.colorDialogDisabledElement);
    }
}
 
源代码5 项目: SuntimesWidget   文件: AlarmDismissActivity.java
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]);
}