List of usage examples for android.support.v4.content ContextCompat getDrawable
public static final Drawable getDrawable(Context context, int i)
From source file:com.justplay1.shoppist.shared.widget.ColorCheckedTextView.java
private void setColor(@ColorInt int color) { StateListDrawable states = new StateListDrawable(); Drawable drawable = ContextCompat.getDrawable(getContext(), R.drawable.btn_radio_to_on_000); Drawable checked = ContextCompat.getDrawable(getContext(), R.drawable.btn_radio_to_on_015); if (isEnabled()) { states.setColorFilter(DrawableUtils.getColorFilter(color)); } else {/* ww w . j a v a 2s .com*/ states.setColorFilter(DrawableUtils.getColorFilter(Color.GRAY)); } states.addState(new int[] { android.R.attr.stateNotNeeded }, drawable); states.addState(new int[] { android.R.attr.state_checked }, checked); states.addState(new int[] { android.R.attr.state_enabled }, drawable); states.addState(new int[] { -android.R.attr.state_enabled, android.R.attr.state_checked }, checked); states.addState(new int[] { -android.R.attr.state_enabled }, drawable); setCheckMarkDrawable(states); }
From source file:by.gdgminsk.animationguide.Sample.java
public Drawable getBullet(Context context) { return ContextCompat.getDrawable(context, mBulletDrawable); }
From source file:com.example.sergey.currentweather.utils.SimpleHorizontalDivider.java
/** * Custom divider will be used */ public SimpleHorizontalDivider(Context context, int resId) { mDivider = ContextCompat.getDrawable(context, resId); }
From source file:com.hippo.nimingban.widget.BottomShadowScrollView.java
public void init(Context context) { mShadowDrawable = ContextCompat.getDrawable(context, R.drawable.shadow_top); mShadowHeight = LayoutUtils.dp2pix(context, 4); }
From source file:com.example.android.supportv4.graphics.DrawableCompatActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.drawable_compat); mImageView = (ImageView) findViewById(R.id.image); Drawable d = ContextCompat.getDrawable(this, IMAGE_RES); mDrawable = DrawableCompat.wrap(d.mutate()); mImageView.setImageDrawable(mDrawable); RadioGroup rg = (RadioGroup) findViewById(R.id.drawable_compat_options); rg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { @Override/*from w ww .j a v a 2s .c om*/ public void onCheckedChanged(RadioGroup radioGroup, int id) { switch (id) { case R.id.drawable_compat_no_tint: clearTint(); break; case R.id.drawable_compat_color: setColorTint(); break; case R.id.drawable_compat_state_list: setColorStateListTint(); break; } } }); }
From source file:android.tumb.com.tumb.Misc.DividerItemDecoration.java
public DividerItemDecoration(Context context, int resId) { mDivider = ContextCompat.getDrawable(context, resId); }
From source file:am.project.x.business.drawables.centerdrawable.CenterDrawableActivity.java
@Override protected void initializeActivity(@Nullable Bundle savedInstanceState) { setSupportActionBar(R.id.cd_toolbar); ImageView image = findViewById(R.id.center_iv_rectangle); image.setImageDrawable(/*from w ww. j a va 2 s .c o m*/ new CenterDrawable(ContextCompat.getDrawable(this, R.drawable.ic_centerdrawable_center), ContextCompat.getColor(this, R.color.colorPrimary))); image = findViewById(R.id.center_iv_rectangle_e); image.setImageDrawable( new CenterDrawable(ContextCompat.getDrawable(this, R.drawable.ic_centerdrawable_center), ContextCompat.getColor(this, R.color.colorPrimary), true)); image = findViewById(R.id.center_iv_rounded_rectangle); CenterDrawable cRR = new CenterDrawable( ContextCompat.getDrawable(this, R.drawable.ic_centerdrawable_center), ContextCompat.getColor(this, R.color.colorPrimary), CenterDrawable.SHAPE_ROUNDED_RECTANGLE, false); cRR.setCornerRadius(getResources().getDisplayMetrics().density * 10); image.setImageDrawable(cRR); image = findViewById(R.id.center_iv_rounded_rectangle_e); CenterDrawable cRRE = new CenterDrawable( ContextCompat.getDrawable(this, R.drawable.ic_centerdrawable_center), ContextCompat.getColor(this, R.color.colorPrimary), CenterDrawable.SHAPE_ROUNDED_RECTANGLE, true); cRRE.setCornerRadius(getResources().getDisplayMetrics().density * 10); image.setImageDrawable(cRRE); image = findViewById(R.id.center_iv_oval); image.setImageDrawable( new CenterDrawable(ContextCompat.getDrawable(this, R.drawable.ic_centerdrawable_center), ContextCompat.getColor(this, R.color.colorPrimary), CenterDrawable.SHAPE_OVAL, false)); image = findViewById(R.id.center_iv_oval_e); image.setImageDrawable( new CenterDrawable(ContextCompat.getDrawable(this, R.drawable.ic_centerdrawable_center), ContextCompat.getColor(this, R.color.colorPrimary), CenterDrawable.SHAPE_OVAL, true)); }
From source file:br.com.oficinatablet.chats.decoration.DividerItemDecoration.java
/** * Divider personalizado ser utilizado */ public DividerItemDecoration(Context context, int resId) { mDivider = ContextCompat.getDrawable(context, resId); }
From source file:ca.rmen.android.scrumchatter.chart.ChartUtils.java
static void addLegendEntry(Context context, ViewGroup legendView, String name, int color) { TextView memberLegendEntry = new TextView(context); memberLegendEntry.setText(name);// ww w. j av a 2 s. c o m memberLegendEntry.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); memberLegendEntry.setPadding(0, 0, context.getResources().getDimensionPixelSize(R.dimen.chart_legend_entry_padding), 0); final Drawable icon; if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { icon = ContextCompat.getDrawable(context, R.drawable.ic_legend_square); memberLegendEntry.setTextColor(color); } else { icon = ContextCompat.getDrawable(context, R.drawable.ic_legend_square).mutate(); DrawableCompat.setTint(icon, color); } memberLegendEntry.setCompoundDrawablesWithIntrinsicBounds(icon, null, null, null); legendView.addView(memberLegendEntry); }
From source file:com.justplay1.shoppist.features.settings.widget.ColorCheckBoxPreference.java
@Override protected void onBindView(View view) { super.onBindView(view); CheckBox checkboxView = (CheckBox) view.findViewById(R.id.checkbox); StateListDrawable states = new StateListDrawable(); Drawable drawable = ContextCompat.getDrawable(getContext(), R.drawable.btn_check_to_on_000); Drawable checked = ContextCompat.getDrawable(getContext(), R.drawable.btn_check_to_on_015); if (isEnabled()) { states.setColorFilter(DrawableUtils.getColorFilter(color)); } else {/*w w w . j a v a2 s .c o m*/ states.setColorFilter(DrawableUtils.getColorFilter(Color.GRAY)); } states.addState(new int[] { android.R.attr.stateNotNeeded }, drawable); states.addState(new int[] { android.R.attr.state_checked }, checked); states.addState(new int[] { android.R.attr.state_enabled }, drawable); states.addState(new int[] { -android.R.attr.state_enabled, android.R.attr.state_checked }, checked); states.addState(new int[] { -android.R.attr.state_enabled }, drawable); checkboxView.setButtonDrawable(states); }