public static void setTint(@NonNull RadioButton radioButton,
@ColorInt int color) {
final int disabledColor = DialogUtils.getDisabledColor(radioButton.getContext());
ColorStateList sl = new ColorStateList(new int[][]{
new int[]{android.R.attr.state_enabled, -android.R.attr.state_checked},
new int[]{android.R.attr.state_enabled, android.R.attr.state_checked},
new int[]{-android.R.attr.state_enabled, -android.R.attr.state_checked},
new int[]{-android.R.attr.state_enabled, android.R.attr.state_checked}
}, new int[]{
DialogUtils.resolveColor(radioButton.getContext(), R.attr.colorControlNormal),
color,
disabledColor,
disabledColor
});
setTint(radioButton, sl);
}
java类com.afollestad.materialdialogs.R的实例源码
MDTintHelper.java 文件源码
项目:GitHub
阅读 24
收藏 0
点赞 0
评论 0
MDRootLayout.java 文件源码
项目:GitHub
阅读 32
收藏 0
点赞 0
评论 0
private void init(Context context, AttributeSet attrs, int defStyleAttr) {
Resources r = context.getResources();
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.MDRootLayout, defStyleAttr, 0);
reducePaddingNoTitleNoButtons = a.getBoolean(R.styleable.MDRootLayout_md_reduce_padding_no_title_no_buttons, true);
a.recycle();
noTitlePaddingFull = r.getDimensionPixelSize(R.dimen.md_notitle_vertical_padding);
buttonPaddingFull = r.getDimensionPixelSize(R.dimen.md_button_frame_vertical_padding);
buttonHorizontalEdgeMargin = r.getDimensionPixelSize(R.dimen.md_button_padding_frame_side);
buttonBarHeight = r.getDimensionPixelSize(R.dimen.md_button_height);
dividerPaint = new Paint();
dividerWidth = r.getDimensionPixelSize(R.dimen.md_divider_height);
dividerPaint.setColor(DialogUtils.resolveColor(context, R.attr.md_divider_color));
setWillNotDraw(false);
}
MDRootLayout.java 文件源码
项目:GitHub
阅读 32
收藏 0
点赞 0
评论 0
@Override public void onFinishInflate() {
super.onFinishInflate();
for (int i = 0; i < getChildCount(); i++) {
View v = getChildAt(i);
if (v.getId() == R.id.md_titleFrame) {
titleBar = v;
} else if (v.getId() == R.id.md_buttonDefaultNeutral) {
buttons[INDEX_NEUTRAL] = (MDButton) v;
} else if (v.getId() == R.id.md_buttonDefaultNegative) {
buttons[INDEX_NEGATIVE] = (MDButton) v;
} else if (v.getId() == R.id.md_buttonDefaultPositive) {
buttons[INDEX_POSITIVE] = (MDButton) v;
} else {
content = v;
}
}
}
MDTintHelper.java 文件源码
项目:EasyFrame
阅读 27
收藏 0
点赞 0
评论 0
public static void setTint(@NonNull RadioButton radioButton, @ColorInt int color) {
ColorStateList sl = new ColorStateList(new int[][]{
new int[]{-android.R.attr.state_checked},
new int[]{android.R.attr.state_checked}
}, new int[]{
DialogUtils.resolveColor(radioButton.getContext(), R.attr.colorControlNormal),
color
});
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
radioButton.setButtonTintList(sl);
} else {
Drawable d = DrawableCompat.wrap(ContextCompat.getDrawable(radioButton.getContext(), R.drawable.abc_btn_radio_material));
DrawableCompat.setTintList(d, sl);
radioButton.setButtonDrawable(d);
}
}
MDTintHelper.java 文件源码
项目:EasyFrame
阅读 29
收藏 0
点赞 0
评论 0
public static void setTint(@NonNull CheckBox box, @ColorInt int color) {
ColorStateList sl = new ColorStateList(new int[][]{
new int[]{-android.R.attr.state_checked},
new int[]{android.R.attr.state_checked}
}, new int[]{
DialogUtils.resolveColor(box.getContext(), R.attr.colorControlNormal),
color
});
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
box.setButtonTintList(sl);
} else {
Drawable drawable = DrawableCompat.wrap(ContextCompat.getDrawable(box.getContext(), R.drawable.abc_btn_check_material));
DrawableCompat.setTintList(drawable, sl);
box.setButtonDrawable(drawable);
}
}
MDRootLayout.java 文件源码
项目:EasyFrame
阅读 27
收藏 0
点赞 0
评论 0
private void init(Context context, AttributeSet attrs, int defStyleAttr) {
Resources r = context.getResources();
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.MDRootLayout, defStyleAttr, 0);
mReducePaddingNoTitleNoButtons = a.getBoolean(R.styleable.MDRootLayout_md_reduce_padding_no_title_no_buttons, true);
a.recycle();
mNoTitlePaddingFull = r.getDimensionPixelSize(R.dimen.md_notitle_vertical_padding);
mButtonPaddingFull = r.getDimensionPixelSize(R.dimen.md_button_frame_vertical_padding);
mButtonHorizontalEdgeMargin = r.getDimensionPixelSize(R.dimen.md_button_padding_frame_side);
mButtonBarHeight = r.getDimensionPixelSize(R.dimen.md_button_height);
mDividerPaint = new Paint();
mDividerWidth = r.getDimensionPixelSize(R.dimen.md_divider_height);
mDividerPaint.setColor(DialogUtils.resolveColor(context, R.attr.md_divider_color));
setWillNotDraw(false);
}
MDRootLayout.java 文件源码
项目:EasyFrame
阅读 27
收藏 0
点赞 0
评论 0
@Override
public void onFinishInflate() {
super.onFinishInflate();
for (int i = 0; i < getChildCount(); i++) {
View v = getChildAt(i);
if (v.getId() == R.id.titleFrame) {
mTitleBar = v;
} else if (v.getId() == R.id.buttonDefaultNeutral) {
mButtons[INDEX_NEUTRAL] = (MDButton) v;
} else if (v.getId() == R.id.buttonDefaultNegative) {
mButtons[INDEX_NEGATIVE] = (MDButton) v;
} else if (v.getId() == R.id.buttonDefaultPositive) {
mButtons[INDEX_POSITIVE] = (MDButton) v;
} else {
mContent = v;
}
}
}
MDTintHelper.java 文件源码
项目:material-dialogs
阅读 27
收藏 0
点赞 0
评论 0
public static void setTint(RadioButton radioButton, @ColorInt int color) {
final int disabledColor = DialogUtils.getDisabledColor(radioButton.getContext());
ColorStateList sl =
new ColorStateList(
new int[][] {
new int[] {android.R.attr.state_enabled, -android.R.attr.state_checked},
new int[] {android.R.attr.state_enabled, android.R.attr.state_checked},
new int[] {-android.R.attr.state_enabled, -android.R.attr.state_checked},
new int[] {-android.R.attr.state_enabled, android.R.attr.state_checked}
},
new int[] {
DialogUtils.resolveColor(radioButton.getContext(), R.attr.colorControlNormal),
color,
disabledColor,
disabledColor
});
setTint(radioButton, sl);
}
MDTintHelper.java 文件源码
项目:material-dialogs
阅读 21
收藏 0
点赞 0
评论 0
public static void setTint(CheckBox box, @ColorInt int color) {
final int disabledColor = DialogUtils.getDisabledColor(box.getContext());
ColorStateList sl =
new ColorStateList(
new int[][] {
new int[] {android.R.attr.state_enabled, -android.R.attr.state_checked},
new int[] {android.R.attr.state_enabled, android.R.attr.state_checked},
new int[] {-android.R.attr.state_enabled, -android.R.attr.state_checked},
new int[] {-android.R.attr.state_enabled, android.R.attr.state_checked}
},
new int[] {
DialogUtils.resolveColor(box.getContext(), R.attr.colorControlNormal),
color,
disabledColor,
disabledColor
});
setTint(box, sl);
}
MDRootLayout.java 文件源码
项目:material-dialogs
阅读 32
收藏 0
点赞 0
评论 0
private void init(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
Resources r = context.getResources();
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.MDRootLayout, defStyleAttr, 0);
reducePaddingNoTitleNoButtons =
a.getBoolean(R.styleable.MDRootLayout_md_reduce_padding_no_title_no_buttons, true);
a.recycle();
noTitlePaddingFull = r.getDimensionPixelSize(R.dimen.md_notitle_vertical_padding);
buttonPaddingFull = r.getDimensionPixelSize(R.dimen.md_button_frame_vertical_padding);
buttonHorizontalEdgeMargin = r.getDimensionPixelSize(R.dimen.md_button_padding_frame_side);
buttonBarHeight = r.getDimensionPixelSize(R.dimen.md_button_height);
dividerPaint = new Paint();
dividerWidth = r.getDimensionPixelSize(R.dimen.md_divider_height);
dividerPaint.setColor(DialogUtils.resolveColor(context, R.attr.md_divider_color));
setWillNotDraw(false);
}
MDRootLayout.java 文件源码
项目:material-dialogs
阅读 27
收藏 0
点赞 0
评论 0
@Override
public void onFinishInflate() {
super.onFinishInflate();
for (int i = 0; i < getChildCount(); i++) {
View v = getChildAt(i);
if (v.getId() == R.id.md_titleFrame) {
titleBar = v;
} else if (v.getId() == R.id.md_buttonDefaultNeutral) {
buttons[INDEX_NEUTRAL] = (MDButton) v;
} else if (v.getId() == R.id.md_buttonDefaultNegative) {
buttons[INDEX_NEGATIVE] = (MDButton) v;
} else if (v.getId() == R.id.md_buttonDefaultPositive) {
buttons[INDEX_POSITIVE] = (MDButton) v;
} else if (v.getId() == R.id.md_promptCheckbox) {
checkPrompt = (CheckBox) v;
} else {
content = v;
}
}
}
MDTintHelper.java 文件源码
项目:GitHub
阅读 27
收藏 0
点赞 0
评论 0
public static void setTint(@NonNull RadioButton radioButton,
@NonNull ColorStateList colors) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
radioButton.setButtonTintList(colors);
} else {
Drawable radioDrawable = ContextCompat.getDrawable(radioButton.getContext(),
R.drawable.abc_btn_radio_material);
Drawable d = DrawableCompat.wrap(radioDrawable);
DrawableCompat.setTintList(d, colors);
radioButton.setButtonDrawable(d);
}
}
MDTintHelper.java 文件源码
项目:GitHub
阅读 26
收藏 0
点赞 0
评论 0
public static void setTint(@NonNull CheckBox box, @ColorInt int color) {
final int disabledColor = DialogUtils.getDisabledColor(box.getContext());
ColorStateList sl = new ColorStateList(new int[][]{
new int[]{android.R.attr.state_enabled, -android.R.attr.state_checked},
new int[]{android.R.attr.state_enabled, android.R.attr.state_checked},
new int[]{-android.R.attr.state_enabled, -android.R.attr.state_checked},
new int[]{-android.R.attr.state_enabled, android.R.attr.state_checked}
}, new int[]{
DialogUtils.resolveColor(box.getContext(), R.attr.colorControlNormal),
color,
disabledColor,
disabledColor
});
setTint(box, sl);
}
MDTintHelper.java 文件源码
项目:GitHub
阅读 28
收藏 0
点赞 0
评论 0
private static ColorStateList createEditTextColorStateList(
@NonNull Context context, @ColorInt int color) {
int[][] states = new int[3][];
int[] colors = new int[3];
int i = 0;
states[i] = new int[]{-android.R.attr.state_enabled};
colors[i] = DialogUtils.resolveColor(context, R.attr.colorControlNormal);
i++;
states[i] = new int[]{-android.R.attr.state_pressed, -android.R.attr.state_focused};
colors[i] = DialogUtils.resolveColor(context, R.attr.colorControlNormal);
i++;
states[i] = new int[]{};
colors[i] = color;
return new ColorStateList(states, colors);
}
MDTintHelper.java 文件源码
项目:EasyFrame
阅读 29
收藏 0
点赞 0
评论 0
private static ColorStateList createEditTextColorStateList(@NonNull Context context, @ColorInt int color) {
int[][] states = new int[3][];
int[] colors = new int[3];
int i = 0;
states[i] = new int[]{-android.R.attr.state_enabled};
colors[i] = DialogUtils.resolveColor(context, R.attr.colorControlNormal);
i++;
states[i] = new int[]{-android.R.attr.state_pressed, -android.R.attr.state_focused};
colors[i] = DialogUtils.resolveColor(context, R.attr.colorControlNormal);
i++;
states[i] = new int[]{};
colors[i] = color;
return new ColorStateList(states, colors);
}
MDTintHelper.java 文件源码
项目:material-dialogs
阅读 26
收藏 0
点赞 0
评论 0
public static void setTint(RadioButton radioButton, ColorStateList colors) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
radioButton.setButtonTintList(colors);
} else {
Drawable radioDrawable =
ContextCompat.getDrawable(radioButton.getContext(), R.drawable.abc_btn_radio_material);
Drawable d = DrawableCompat.wrap(radioDrawable);
DrawableCompat.setTintList(d, colors);
radioButton.setButtonDrawable(d);
}
}
MDTintHelper.java 文件源码
项目:material-dialogs
阅读 24
收藏 0
点赞 0
评论 0
private static ColorStateList createEditTextColorStateList(Context context, @ColorInt int color) {
int[][] states = new int[3][];
int[] colors = new int[3];
int i = 0;
states[i] = new int[] {-android.R.attr.state_enabled};
colors[i] = DialogUtils.resolveColor(context, R.attr.colorControlNormal);
i++;
states[i] = new int[] {-android.R.attr.state_pressed, -android.R.attr.state_focused};
colors[i] = DialogUtils.resolveColor(context, R.attr.colorControlNormal);
i++;
states[i] = new int[] {};
colors[i] = color;
return new ColorStateList(states, colors);
}
MDButton.java 文件源码
项目:GitHub
阅读 24
收藏 0
点赞 0
评论 0
private void init(Context context) {
stackedEndPadding = context.getResources()
.getDimensionPixelSize(R.dimen.md_dialog_frame_margin);
stackedGravity = GravityEnum.END;
}
ProgressDrawableBase.java 文件源码
项目:EasyFrame
阅读 20
收藏 0
点赞 0
评论 0
public ProgressDrawableBase(Context context) {
int colorControlActivated = DialogUtils.resolveColor(context, R.attr.colorControlActivated);
// setTint() has been overridden for compatibility; DrawableCompat won't work because
// wrapped Drawable won't be Animatable.
setTint(colorControlActivated);
}
MDButton.java 文件源码
项目:EasyFrame
阅读 22
收藏 0
点赞 0
评论 0
private void init(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
mStackedEndPadding = context.getResources()
.getDimensionPixelSize(R.dimen.md_dialog_frame_margin);
mStackedGravity = GravityEnum.END;
}
MDButton.java 文件源码
项目:material-dialogs
阅读 33
收藏 0
点赞 0
评论 0
private void init(Context context) {
stackedEndPadding =
context.getResources().getDimensionPixelSize(R.dimen.md_dialog_frame_margin);
stackedGravity = GravityEnum.END;
}