List of usage examples for android.widget ImageView setImageResource
@android.view.RemotableViewMethod(asyncImpl = "setImageResourceAsync") public void setImageResource(@DrawableRes int resId)
From source file:Main.java
public static void startFrameAnimation(ImageView targetImageView, int animationDrawableId) { if (targetImageView == null || animationDrawableId <= 0) { return;// ww w . j a v a 2 s .c om } targetImageView.setImageResource(animationDrawableId); AnimationDrawable animationDrawable = (AnimationDrawable) targetImageView.getDrawable(); animationDrawable.start(); }
From source file:Main.java
public static void startActivity(final Activity thisActivity, final Intent intent, final View triggerView, int colorOrImageRes, final long durationMills) { int[] location = new int[2]; triggerView.getLocationInWindow(location); final int cx = location[0] + triggerView.getWidth(); final int cy = location[1] + triggerView.getHeight() + (int) TypedValue .applyDimension(TypedValue.COMPLEX_UNIT_DIP, 160, thisActivity.getResources().getDisplayMetrics()); final ImageView view = new ImageView(thisActivity); view.setScaleType(ImageView.ScaleType.CENTER_CROP); view.setImageResource(colorOrImageRes); final ViewGroup decorView = (ViewGroup) thisActivity.getWindow().getDecorView(); int w = decorView.getWidth(); int h = decorView.getHeight(); decorView.addView(view, w, h);/*from w w w .j a v a 2 s .c o m*/ final int finalRadius = (int) Math.sqrt(w * w + h * h) + 1; Animator anim = ViewAnimationUtils.createCircularReveal(view, cx, cy, 0, finalRadius); anim.setDuration(durationMills); anim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); thisActivity.startActivity(intent); thisActivity.overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out); } }); anim.start(); }
From source file:com.ouyangzn.github.utils.UiUtils.java
/** * toolbar//from ww w . jav a2 s. co m * * @param toolbar toolbar * @param resId ?id * @param gravity ?{@link Gravity#LEFT}?{@link Gravity#RIGHT} * @param margin ?{@link Toolbar.LayoutParams#setMargins(int, int, int, int)} * @return ImageView */ public static ImageView addImage2Toolbar(Toolbar toolbar, int resId, int gravity, int[] margin) { Context context = toolbar.getContext(); ImageView img = new ImageView(context); img.setImageResource(resId); img.setScaleType(ImageView.ScaleType.CENTER_INSIDE); Toolbar.LayoutParams params = new Toolbar.LayoutParams(Toolbar.LayoutParams.WRAP_CONTENT, Toolbar.LayoutParams.WRAP_CONTENT); params.gravity = gravity | Gravity.CENTER; try { params.setMargins(margin[0], margin[1], margin[2], margin[3]); } catch (Exception e) { int margin_15 = ScreenUtils.dp2px(context, 15); params.setMargins(margin_15, 0, margin_15, 0); } img.setLayoutParams(params); toolbar.addView(img); return img; }
From source file:com.beck.matthew.customtabs.MainActivity.java
private static View createTabView(final Context context, final String text, int imageResource) { @SuppressLint("InflateParams") View view = LayoutInflater.from(context).inflate(R.layout.tab_layout, null); TextView textView = (TextView) view.findViewById(R.id.tabsText); textView.setText(text);//from www .j a v a2 s.co m ImageView imageView = (ImageView) view.findViewById(R.id.tabsImage); imageView.setImageResource(imageResource); return view; }
From source file:com.doctoror.fuckoffmusicplayer.presentation.util.BindingAdapters.java
@BindingAdapter("srcRes") public static void setImageResource(@NonNull final ImageView imageView, @DrawableRes final int src) { imageView.setImageResource(src); }
From source file:Main.java
private static ImageView newStar(Activity activity, int drawableResId) { ImageView star = new ImageView(activity); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); star.setLayoutParams(params);/*from w w w. ja va2s . c o m*/ star.setImageResource(drawableResId); return star; }
From source file:Main.java
private static void preloadImage(ImageView imageView, int placeholderImageResource, Message msg) { // set the default image first, when the query is complete, we will // replace the image with the correct one. if (placeholderImageResource != -1) { imageView.setVisibility(View.VISIBLE); imageView.setImageResource(placeholderImageResource); } else {/*from w ww . java 2 s . c o m*/ imageView.setVisibility(View.INVISIBLE); } // notify the thread to begin working sThreadHandler.sendMessage(msg); }
From source file:com.hackeruproj.android.havatzfit.general_utilities.GenUtils.java
public static void menuAlerts(Context context, int header, int theme, int img) { AlertDialog.Builder menuBuilder = new AlertDialog.Builder(context); LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View menuView = inflater.inflate(R.layout.inflater_alertdialog, null); menuBuilder.setView(menuView);//from w ww . ja va 2s. c o m TextView headerText = (TextView) menuView.findViewById(R.id.alertTxtHeader); TextView bodyText = (TextView) menuView.findViewById(R.id.alertTxtBody); ImageView imgView = (ImageView) menuView.findViewById(R.id.alertImgBody); headerText.setText(header); bodyText.setText(theme); imgView.setImageResource(img); menuBuilder.setNeutralButton("Ok", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); menuBuilder.show(); }
From source file:Main.java
private static void loadAssetImage(ImageView view, String filename, int defaultIconId) { InputStream input = null;//from w w w . j a va2s . co m try { input = view.getContext().getAssets().open(filename); Bitmap icon = BitmapFactory.decodeStream(input); view.setImageBitmap(icon); input.close(); } catch (Exception error) { view.setImageResource(defaultIconId); } finally { silentClose(input); } }
From source file:org.youaretheone.website.client.UoneSearchGsonActivity.java
private static View createTabView(final Context context, final String text, int iconResource) { View view = LayoutInflater.from(context).inflate(R.layout.tabs_layout, null); TextView tv = (TextView) view.findViewById(R.id.tabsText); tv.setText(text);//from ww w .jav a2 s.c o m ImageView icon = (ImageView) view.findViewById(R.id.tabsIcon); icon.setImageResource(iconResource); return view; }