Java Code Examples for android.support.v7.widget.AppCompatDrawableManager#get()
The following examples show how to use
android.support.v7.widget.AppCompatDrawableManager#get() .
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: PickerThemeUtils.java From AppCompat-Extension-Library with Apache License 2.0 | 6 votes |
public static void setNavButtonDrawable(Context context, ImageButton left, ImageButton right, int monthTextAppearanceResId) { // Retrieve the previous and next drawables AppCompatDrawableManager dm = AppCompatDrawableManager.get(); Drawable prevDrawable = dm.getDrawable(context, R.drawable.ic_chevron_left_black_24dp); Drawable nextDrawable = dm.getDrawable(context, R.drawable.ic_chevron_right_black_24dp); // Proxy the month text color into the previous and next drawables. final TypedArray ta = context.obtainStyledAttributes(null, new int[]{android.R.attr.textColor}, 0, monthTextAppearanceResId); final ColorStateList monthColor = ta.getColorStateList(0); if (monthColor != null) { DrawableCompat.setTint(DrawableCompat.wrap(prevDrawable), monthColor.getDefaultColor()); DrawableCompat.setTint(DrawableCompat.wrap(nextDrawable), monthColor.getDefaultColor()); } ta.recycle(); // Set the previous and next drawables left.setImageDrawable(prevDrawable); right.setImageDrawable(nextDrawable); }
Example 2
Source File: AccountAdapter.java From AppCompat-Extension-Library with Apache License 2.0 | 5 votes |
private static void setupCheckBox(CheckBox checkBox) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { checkBox.setButtonDrawable(R.drawable.btn_checkbox_circle); checkBox.setBackgroundResource(R.drawable.btn_checkbox_circle_background); } else { Context context = checkBox.getContext(); AppCompatDrawableManager dm = AppCompatDrawableManager.get(); StateListDrawable button = new StateListDrawable(); button.addState(new int[]{android.R.attr.state_checked}, dm.getDrawable(context, R.drawable.ic_checkbox_circle_checked)); button.addState(new int[]{}, dm.getDrawable(context, R.drawable.ic_checkbox_circle_unchecked)); ColorStateList buttonTint = new ColorStateList(new int[][]{ // states new int[]{android.R.attr.state_checked}, new int[]{} // state_default }, new int[]{ // colors ThemeUtils.getThemeAttrColor(context, R.attr.colorControlActivated), ThemeUtils.getThemeAttrColor(context, R.attr.colorControlNormal) }); Drawable buttonCompat = DrawableCompat.wrap(button); DrawableCompat.setTintList(buttonCompat, buttonTint); checkBox.setButtonDrawable(buttonCompat); ShapeDrawable background = new ShapeDrawable(new OvalShape()); int backgroundTint = ThemeUtils.getThemeAttrColor(context, android.R.attr.colorBackground); Drawable backgroundCompat = DrawableCompat.wrap(background); DrawableCompat.setTint(backgroundCompat, backgroundTint); ViewCompatUtils.setBackground(checkBox, backgroundCompat); } }
Example 3
Source File: SampleActivity.java From CompositionAvatar with MIT License | 4 votes |
private void vector(CompositionAvatarView view) { AppCompatDrawableManager drawableManager = AppCompatDrawableManager.get(); view.addDrawable(drawableManager.getDrawable(this, R.drawable.cloud_circle)); view.addDrawable(drawableManager.getDrawable(this, R.drawable.album)); view.addDrawable(drawableManager.getDrawable(this, R.drawable.group_work)); }