@SuppressWarnings("deprecation") private static void setBackgroundCompat(View view, Drawable drawable) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) { view.setBackgroundDrawable(drawable); } else { view.setBackground(drawable); } }
private void applyDropHint(View v, int drawableId) { View parent=(View)v.getParent(); if (drawableId>-1) { parent.setBackgroundResource(drawableId); } else { parent.setBackground(null); } }
GradientDrawable shape = new GradientDrawable(); shape.setCornerRadius( 8 ); // add some color // You can add your random color generator here // and set color if (i % 2 == 0) { shape.setColor(Color.RED); } else { shape.setColor(Color.BLUE); } // now find your view and add background to it View view = (LinearLayout) findViewById( R.id.my_view ); view.setBackground(shape);
private void applyDropHint(View v, int drawableId) { View parent=(View)v.getParent(); if (drawableId>-1) { parent.setBackgroundResource(drawableId); } else { parent.setBackground(null); } }
public static void setBackground(View v, Drawable drawable){ if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) v.setBackground(drawable); else v.setBackgroundDrawable(drawable); }
private View addViewToOverlay(ViewGroup sceneRoot, int width, int height, Drawable background) { View view = new NoOverlapView(sceneRoot.getContext()); view.setBackground(background); int widthSpec = View.MeasureSpec.makeMeasureSpec(width, View.MeasureSpec.EXACTLY); int heightSpec = View.MeasureSpec.makeMeasureSpec(height, View.MeasureSpec.EXACTLY); view.measure(widthSpec, heightSpec); view.layout(0, 0, width, height); sceneRoot.getOverlay().add(view); return view; }
private void applyDropHint(View v, int drawableId) { View parent=(View)v.getParent(); if (drawableId>-1) { parent.setBackgroundResource(drawableId); } else { parent.setBackground(null); } }
private void setBackground(Drawable backgroundDrawable) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) { mView.setBackgroundDrawable(backgroundDrawable); } else { mView.setBackground(backgroundDrawable); } }
private void applyDropHint(View v, int drawableId) { View parent=(View)v.getParent(); if (drawableId>-1) { parent.setBackgroundResource(drawableId); } else { parent.setBackground(null); } }
public static void setBackground(View view, Drawable background) { if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { view.setBackground(background); } else { view.setBackgroundDrawable(background); } }
private void applyDropHint(View v, int drawableId) { if (v!=info) { v=(View)v.getParent(); } if (drawableId>-1) { v.setBackgroundResource(drawableId); } else { v.setBackground(null); } }
public static void setBackground(View v, Drawable drawable) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { v.setBackground(drawable); } else { v.setBackgroundDrawable(drawable); } }
private void applyDropHint(View v, int drawableId) { View parent=(View)v.getParent(); if (drawableId>-1) { parent.setBackgroundResource(drawableId); } else { parent.setBackground(null); } }
static void setBackground(@NonNull View view, Drawable drawable) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) view.setBackground(drawable); else view.setBackgroundDrawable(drawable); }
private void applyDropHint(View v, int drawableId) { View parent=(View)v.getParent(); if (drawableId>-1) { parent.setBackgroundResource(drawableId); } else { parent.setBackground(null); } }
@TargetApi(Build.VERSION_CODES.JELLY_BEAN) public static void setBackground(View view, Drawable drawable) { if (Build.VERSION.SDK_INT < 16) { //noinspection deprecation view.setBackgroundDrawable(drawable); } else { view.setBackground(drawable); } }
private void applyDropHint(View v, int drawableId) { View parent=(View)v.getParent(); if (drawableId>-1) { parent.setBackgroundResource(drawableId); } else { parent.setBackground(null); } }
private void applyDropHint(View v, int drawableId) { View parent=(View)v.getParent(); if (drawableId>-1) { parent.setBackgroundResource(drawableId); } else { parent.setBackground(null); } }
private void applyDropHint(View v, int drawableId) { View parent=(View)v.getParent(); if (drawableId>-1) { parent.setBackgroundResource(drawableId); } else { parent.setBackground(null); } }
private void applyDropHint(View v, int drawableId) { View parent=(View)v.getParent(); if (drawableId>-1) { parent.setBackgroundResource(drawableId); } else { parent.setBackground(null); } }