List of usage examples for android.view View setBackgroundResource
@RemotableViewMethod public void setBackgroundResource(@DrawableRes int resid)
From source file:Main.java
public static void startAnimation(int resId, View view) { view.setBackgroundResource(resId); ((AnimationDrawable) view.getBackground()).start(); }
From source file:Main.java
/** * Start given animation on provided view. *///from w ww .j a v a 2s . c om public static void startAnimation(View view, int animationId) { view.setBackgroundResource(animationId); AnimationDrawable animationDrawable = (AnimationDrawable) view.getBackground(); if (animationDrawable != null) { animationDrawable.start(); } }
From source file:Main.java
public static void setBackgroundResource(View view, int id, int resId) { View viewImage = findViewById(view, id); viewImage.setBackgroundResource(resId); }
From source file:com.irccloud.android.data.BackgroundBindingAdapter.java
@BindingAdapter("android:background") public static void setBackground(View view, int res) { if (res > 0) view.setBackgroundResource(res); else/*w ww .j a v a 2 s. c o m*/ view.setBackgroundDrawable(null); }
From source file:com.example.ysh.myapplication.view.readview.ThemeManager.java
public static void setReaderTheme(int theme, View view) { switch (theme) { case NORMAL:/*ww w .ja va2 s . co m*/ view.setBackgroundResource(R.drawable.theme_white_bg); break; case YELLOW: view.setBackgroundResource(R.drawable.theme_yellow_bg); break; case GREEN: view.setBackgroundResource(R.drawable.theme_green_bg); break; case LEATHER: view.setBackgroundResource(R.drawable.theme_leather_bg); break; case GRAY: view.setBackgroundResource(R.drawable.theme_gray_bg); break; case NIGHT: view.setBackgroundResource(R.drawable.theme_night_bg); break; default: break; } }
From source file:Main.java
public static void updateRight(View view, int resourceId) { if (view != null && view instanceof ImageView) { ((ImageView) view).setImageResource(resourceId); } else {//from w w w . j a v a2 s . com view.setBackgroundResource(resourceId); } view.setVisibility(View.VISIBLE); }
From source file:Main.java
public static void setFixedDrableBg(View v, int drawAbRes) { int bottom = v.getPaddingBottom(); int top = v.getPaddingTop(); int right = v.getPaddingRight(); int left = v.getPaddingLeft(); v.setBackgroundResource(drawAbRes); v.setPadding(left, top, right, bottom); }
From source file:com.github.pennyfive.cinemafinlando.ui.UiUtils.java
public static View inflateDefaultLoadingView(Context context, int backgroundResource) { View view = View.inflate(context, R.layout.state_loading, null); view.setBackgroundResource(backgroundResource); view.findViewById(R.id.spinner)/* w w w. j ava2s.c o m*/ .startAnimation(AnimationUtils.loadAnimation(context, R.anim.spinner_spin_around)); return view; }
From source file:Main.java
public static void setViewBackgroundWithoutResettingPadding(final View v, final int backgroundResId) { final int paddingBottom = v.getPaddingBottom(), paddingLeft = v.getPaddingLeft(); final int paddingRight = v.getPaddingRight(), paddingTop = v.getPaddingTop(); v.setBackgroundResource(backgroundResId); v.setPadding(paddingLeft, paddingTop, paddingRight, paddingBottom); }
From source file:Main.java
/** * Sets the background of a view to the given 9-patch resource and restores its padding. This * works around a bug in Android where the padding is lost when a 9-patch resource is applied * programmatically.// w w w.j a v a2 s. c o m */ public static void setNinePatchBackgroundResource(View view, @DrawableRes int resource) { int left = view.getPaddingLeft(); int top = view.getPaddingTop(); int right = view.getPaddingRight(); int bottom = view.getPaddingBottom(); view.setBackgroundResource(resource); view.setPadding(left, top, right, bottom); }