List of usage examples for android.view View getBackground
public Drawable getBackground()
From source file:com.micabyte.android.app.BaseActivity.java
private static void unbindViewReferences(View view) { // set all listeners to null try {/* ww w .j a va 2s. c o m*/ view.setOnClickListener(null); } catch (Throwable mayHappen) { // NOOP - not supported by all views/versions } try { view.setOnCreateContextMenuListener(null); } catch (Throwable mayHappen) { // NOOP - not supported by all views/versions } try { view.setOnFocusChangeListener(null); } catch (Throwable mayHappen) { // NOOP - not supported by all views/versions } try { view.setOnKeyListener(null); } catch (Throwable mayHappen) { // NOOP - not supported by all views/versions } try { view.setOnLongClickListener(null); } catch (Throwable mayHappen) { // NOOP - not supported by all views/versions } try { view.setOnClickListener(null); } catch (Throwable mayHappen) { // NOOP - not supported by all views/versions } // set background to null Drawable d = view.getBackground(); if (d != null) { d.setCallback(null); } if (view instanceof ImageView) { final ImageView imageView = (ImageView) view; d = imageView.getDrawable(); if (d != null) { d.setCallback(null); } imageView.setImageDrawable(null); imageView.setImageBitmap(null); } if (view instanceof ImageButton) { final ImageButton imageB = (ImageButton) view; d = imageB.getDrawable(); if (d != null) { d.setCallback(null); } imageB.setImageDrawable(null); } // destroy WebView if (view instanceof WebView) { view.destroyDrawingCache(); ((WebView) view).destroy(); } }
From source file:fr.shywim.antoinedaniel.ui.fragment.SoundPagerFragment.java
private void setFabMiniUnchecked(View view) { view.getBackground().mutate().clearColorFilter(); }
From source file:fr.shywim.antoinedaniel.ui.fragment.SoundPagerFragment.java
private void setFabMiniChecked(View view) { view.getBackground().mutate().setColorFilter(getResources().getColor(R.color.primary_lighter), PorterDuff.Mode.SRC_ATOP);//from w w w . ja va 2s.c o m }
From source file:com.gh4a.adapter.RootAdapter.java
@Override public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { if (holder instanceof FooterViewHolder) { if (mFooterListener != null) { mFooterListener.onScrolledToFooter(); }//from w w w.j a v a 2 s .c o m } else if (!(holder instanceof HeaderViewHolder)) { onBindViewHolder((VH) holder, getItemFromAdapterPosition(position)); if (position == mHighlightPosition) { final View v = holder.itemView; v.post(new Runnable() { @Override public void run() { if (v.getBackground() != null) { final int centerX = v.getWidth() / 2; final int centerY = v.getHeight() / 2; DrawableCompat.setHotspot(v.getBackground(), centerX, centerY); } v.setPressed(true); v.setPressed(false); mHighlightPosition = -1; } }); } } }
From source file:org.totschnig.myexpenses.util.Utils.java
public static void setBackgroundFilter(View v, int c) { v.getBackground().setColorFilter(c, PorterDuff.Mode.MULTIPLY); }
From source file:com.awt.supark.LayoutHandler.java
public void appBackgroundColorChange(View view, int time, int r, int g, int b) { ColorDrawable wBack = (ColorDrawable) view.getBackground(); int color = wBack.getColor(); int r1 = Color.red(color); int g1 = Color.green(color); int b1 = Color.blue(color); ObjectAnimator colorFade = ObjectAnimator.ofObject(view, "backgroundColor", new ArgbEvaluator(), Color.argb(255, r1, g1, b1), Color.argb(255, r, g, b)); colorFade.setDuration(time);/*from ww w . jav a2 s . c o m*/ colorFade.start(); }
From source file:com.cloverstudio.spika.extendables.SpikaActivity.java
protected void unbindDrawables(View view) { if (view.getBackground() != null) { view.getBackground().setCallback(null); }//from ww w . j av a 2s .c o m if (view instanceof ViewGroup) { for (int i = 0; i < ((ViewGroup) view).getChildCount(); i++) { unbindDrawables(((ViewGroup) view).getChildAt(i)); } ((ViewGroup) view).removeAllViews(); } }
From source file:com.geekandroid.sdk.base.BaseActivity.java
@Override public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN://start to touch the view if (v.getBackground() != null) { /**/*w ww .j av a2 s. c o m*/ * set background is color */ if ((v.getBackground() instanceof ColorDrawable)) { v.setTag(((ColorDrawable) v.getBackground()).getColor()); v.setBackgroundColor(getResources().getColor(android.R.color.darker_gray)); } else { /** * set background is drawable if you want change saturationby use variable */ v.setTag(""); colorMatrix.setSaturation(saturation); colorMatrixColorFilter = new ColorMatrixColorFilter(colorMatrix); v.getBackground().setColorFilter(colorMatrixColorFilter); } } /** * have not set background */ else { v.setBackgroundColor(getResources().getColor(android.R.color.darker_gray)); v.setTag(null); } break; case MotionEvent.ACTION_UP://when the finger leave the screen case MotionEvent.ACTION_CANCEL://cancel the action /** * retrieve background is color */ if (v.getTag() instanceof Integer) { v.setBackgroundColor((Integer) v.getTag()); } else if (v.getTag() instanceof String) { colorMatrix.setSaturation(1); colorMatrixColorFilter = new ColorMatrixColorFilter(colorMatrix); v.getBackground().setColorFilter(colorMatrixColorFilter); } else { v.setBackgroundColor(getResources().getColor(android.R.color.transparent)); } v.setTag(null); break; default: break; } mGestureDetector.onTouchEvent(event); return false; }
From source file:at.bitfire.davdroid.ui.CreateCalendarActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); account = getIntent().getExtras().getParcelable(EXTRA_ACCOUNT); getSupportActionBar().setDisplayHomeAsUpEnabled(true); setContentView(R.layout.activity_create_calendar); final View colorSquare = findViewById(R.id.color); colorSquare.setOnClickListener(new View.OnClickListener() { @Override/* ww w. j av a 2s .c o m*/ public void onClick(View v) { new AmbilWarnaDialog(CreateCalendarActivity.this, ((ColorDrawable) colorSquare.getBackground()).getColor(), true, new AmbilWarnaDialog.OnAmbilWarnaListener() { @Override public void onCancel(AmbilWarnaDialog dialog) { } @Override public void onOk(AmbilWarnaDialog dialog, int color) { colorSquare.setBackgroundColor(color); } }).show(); } }); getSupportLoaderManager().initLoader(0, null, this); }
From source file:com.mobicage.rogerthat.util.ui.UIUtils.java
public static void setColors(int color, View... views) { if (Build.VERSION.SDK_INT >= 27) { return;// w w w .j a v a2 s. c o m } for (View view : views) { if (view instanceof CheckBox) { CheckBox checkbox = (CheckBox) view; CompoundButtonCompat.setButtonTintList(checkbox, ColorStateList.valueOf(color)); } else if (view instanceof FloatingActionButton) { //noinspection RedundantCast ((FloatingActionButton) view).setBackgroundTintList(ColorStateList.valueOf(color)); } else if (view instanceof Button || view instanceof ImageButton) { Drawable background = view.getBackground(); if (background != null) { background.setColorFilter(color, PorterDuff.Mode.SRC_IN); } } else if (view instanceof TextInputLayout) { UIUtils.colorTextInputLayout((TextInputLayout) view, color); // TODO: EditText's who are a child of TextInputLayout their line isn't colored correctly } else if (view instanceof EditText) { EditText editText = (EditText) view; editText.setHighlightColor(color); // When selecting text editText.setHintTextColor(color); // Text for the hint message // Line under the textfield Drawable background = editText.getBackground(); if (background != null) { DrawableCompat.setTint(background, color); editText.setBackground(background); } UIUtils.setCursorColor(editText, color); } else if (view instanceof CheckedTextView) { CheckedTextView ctv = (CheckedTextView) view; Drawable d = ctv.getCheckMarkDrawable(); d.setColorFilter(color, PorterDuff.Mode.SRC_IN); } else if (view instanceof TextView) { ((TextView) view).setLinkTextColor(color); } else if (view instanceof SeekBar) { SeekBar sb = (SeekBar) view; Drawable progress = sb.getProgressDrawable(); if (progress != null) { progress.setColorFilter(color, PorterDuff.Mode.SRC_IN); } Drawable thumb = sb.getThumb(); if (thumb != null) { thumb.setColorFilter(color, PorterDuff.Mode.SRC_IN); } } else if (view instanceof ProgressBar) { ((ProgressBar) view).getIndeterminateDrawable().setColorFilter(color, PorterDuff.Mode.SRC_IN); } else { L.d("Not coloring view: " + view.toString()); } } }