List of usage examples for android.view View getResources
public Resources getResources()
From source file:Main.java
public static int orientation(View paramView) { return paramView.getResources().getConfiguration().orientation; }
From source file:Main.java
public static Bitmap getBitmapFromResId(View a, int id) { return ((BitmapDrawable) a.getResources().getDrawable(id)).getBitmap(); }
From source file:Main.java
public static int getPixels(View v, double dipValue) { return getPixels(v.getResources(), dipValue); }
From source file:Main.java
public static View findViewInList(Activity activity, ListView list, int index, String string) { View view = getViewInList(list, index); return view.findViewById(view.getResources().getIdentifier(string, "id", activity.getPackageName())); }
From source file:Main.java
public static void background(@NonNull View v, Bitmap b) { background(v, new BitmapDrawable(v.getResources(), b)); }
From source file:Main.java
/** * Sets background from drawable resource * /*from w w w. ja va2 s . com*/ * @param view * view object for set drawable resource * @param resourceId * drawable resource */ @SuppressWarnings("deprecation") @SuppressLint("NewApi") public static void setBg(View view, final int resourceId) { Drawable res = view.getResources().getDrawable(resourceId); if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) { view.setBackgroundDrawable(res); } else { view.setBackground(res); } }
From source file:Main.java
/** * Set the background of a {@link android.view.View} to the specified color, with a darker version of the * color as a border.//from w w w . j a va 2 s. c om */ public static void setViewBackground(View view, int color) { Resources r = view.getResources(); Drawable currentDrawable = view.getBackground(); GradientDrawable backgroundDrawable; if (currentDrawable != null && currentDrawable instanceof GradientDrawable) { // Reuse drawable backgroundDrawable = (GradientDrawable) currentDrawable; } else { backgroundDrawable = new GradientDrawable(); } int darkenedColor = darkenColor(color); backgroundDrawable.setColor(color); backgroundDrawable.setStroke( (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 1, r.getDisplayMetrics()), darkenedColor); view.setBackgroundDrawable(backgroundDrawable); }
From source file:Main.java
public static int getPixelFromDIP(final View view, int value) { return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, value, view.getResources().getDisplayMetrics()); }
From source file:Main.java
public static void shake(View v) { final float distance = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 4.0f, v.getResources().getDisplayMetrics()); final ObjectAnimator animator = ObjectAnimator.ofFloat(v, "translationX", 0, distance, 0, -distance, 0); animator.setRepeatMode(ObjectAnimator.RESTART); animator.setInterpolator(new LinearInterpolator()); animator.setRepeatCount(4);/*from w w w . j a v a 2 s .c o m*/ animator.setDuration(150); animator.start(); }
From source file:Main.java
/** * @param dp Desired size in dp (density-independent pixels) * @param v View//w ww . j ava2 s . c o m * @return Number of corresponding density-dependent pixels for the given device */ static int getDP(int dp, View v) { return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, v.getResources().getDisplayMetrics()); }