List of usage examples for android.graphics.drawable GradientDrawable setColor
public void setColor(@Nullable ColorStateList colorStateList)
From source file:com.example.android.materialme.DetailActivity.java
/** * Initializes the activity, filling in the data from the Intent. * @param savedInstanceState Contains information about the saved state of the activity *///from w ww . j a va 2 s.c om @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_detail); //Initialize the views TextView sportsTitle = (TextView) findViewById(R.id.titleDetail); ImageView sportsImage = (ImageView) findViewById(R.id.sportsImageDetail); //Get the drawable Drawable drawable = ContextCompat.getDrawable(this, getIntent().getIntExtra(Sport.IMAGE_KEY, 0)); //Create a placeholder gray scrim while the image loads GradientDrawable gradientDrawable = new GradientDrawable(); gradientDrawable.setColor(Color.GRAY); //Make it the same size as the image if (drawable != null) { gradientDrawable.setSize(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight()); } //Set the text from the Intent extra sportsTitle.setText(getIntent().getStringExtra(Sport.TITLE_KEY)); //Load the image using the glide library and the Intent extra Glide.with(this).load(getIntent().getIntExtra(Sport.IMAGE_KEY, 0)).placeholder(gradientDrawable) .into(sportsImage); }
From source file:com.intirix.cloudpasswordmanager.pages.settings.SavePasswordOptionsViewHolder.java
private void addBorder(View view) { //use a GradientDrawable with only one color set, to make it a solid color GradientDrawable border = new GradientDrawable(); border.setColor(0xFFFFFFFF); //white background border.setStroke(1, 0xFF000000); //black border with full opacity if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) { view.setBackgroundDrawable(border); } else {/* w w w .ja va 2 s . co m*/ view.setBackground(border); } }
From source file:com.intirix.cloudpasswordmanager.pages.settings.SavePasswordOptionsViewHolder.java
private void removeBorder(View view) { //use a GradientDrawable with only one color set, to make it a solid color GradientDrawable border = new GradientDrawable(); border.setColor(0xFFFFFFFF); //white background border.setStroke(0, 0xFF000000); //black border with full opacity if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) { view.setBackgroundDrawable(border); } else {// w ww .j a v a2s. c o m view.setBackground(border); } }
From source file:com.bartoszlipinski.flippablestackview.sample.fragment.ColorFragment.java
@Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View v = inflater.inflate(R.layout.fragment_dummy, container, false); Bundle bdl = getArguments();//ww w .ja v a2 s . com mMainLayout = (FrameLayout) v.findViewById(R.id.main_layout); LayerDrawable bgDrawable = (LayerDrawable) mMainLayout.getBackground(); GradientDrawable shape = (GradientDrawable) bgDrawable.findDrawableByLayerId(R.id.background_shape); shape.setColor(bdl.getInt(EXTRA_COLOR)); return v; }
From source file:com.oxapps.materialcountdown.view.CircularIconImageView.java
@Override public void setBackgroundColor(int color) { GradientDrawable d = (GradientDrawable) ContextCompat.getDrawable(getContext(), R.drawable.circle_drawable); d.setColor(color); super.setBackground(d); }
From source file:com.oxapps.materialcountdown.view.CircularIconImageView.java
@Override public void setBackground(Drawable background) { ColorDrawable cd = (ColorDrawable) background; GradientDrawable d = (GradientDrawable) ContextCompat.getDrawable(getContext(), R.drawable.circle_drawable); d.setColor(cd.getColor()); super.setBackground(d); }
From source file:com.actionbarsherlock.sample.styledactionbar.RoundedColourFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.mView = new View(this.getActivity()); GradientDrawable background = (GradientDrawable) this.getResources().getDrawable(R.drawable.rounded_rect); background.setColor(this.mColor); this.mView.setBackgroundDrawable(background); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(0, LayoutParams.FILL_PARENT, mWeight); lp.setMargins(this.mMarginLeft, this.mMarginTop, this.mMarginRight, this.mMarginBottom); this.mView.setLayoutParams(lp); }
From source file:com.bartoszlipinski.recyclerviewheader2.sample.adapter.ColorItemsAdapter.java
@Override public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { SampleViewHolder viewHolder = (SampleViewHolder) holder; LayerDrawable bgDrawable = (LayerDrawable) viewHolder.mainLayout.getBackground(); GradientDrawable shape = (GradientDrawable) bgDrawable.findDrawableByLayerId(R.id.background_shape); shape.setColor(colors[position]); }
From source file:com.savvisingh.colorpickerdialog.ColorPickerSwatch.java
protected void setColor(int color) { GradientDrawable drawable = (GradientDrawable) ContextCompat.getDrawable(getContext(), R.drawable.circle); drawable.setColor(color); mSwatchImage.setImageDrawable(drawable); }
From source file:com.forrestguice.suntimeswidget.LightMapDialog.java
private void colorizeImageView(ImageView view, int color) { if (view.getBackground() != null) { GradientDrawable d = (GradientDrawable) view.getBackground().mutate(); d.setColor(color); d.invalidateSelf();/*from w ww. j a v a 2 s .c o m*/ } }