private Bitmap loadAndPrintDpi(int id, boolean scale) { Bitmap bitmap; if (scale) { bitmap = BitmapFactory.decodeResource(getResources(), id); } else { BitmapFactory.Options opts = new BitmapFactory.Options(); opts.inScaled = false; bitmap = BitmapFactory.decodeResource(getResources(), id, opts); } return bitmap; }
private Bitmap loadAndPrintDpi(int id, boolean scale) { Bitmap bitmap; if (scale) { bitmap = BitmapFactory.decodeResource(getResources(), id); } else { BitmapFactory.Options opts = new BitmapFactory.Options(); opts.inScaled = false; bitmap = BitmapFactory.decodeResource(getResources(), id, opts); } return bitmap; }
private void addResourceDrawable(LinearLayout layout, int resource) { View view = new View(this); final Drawable d = getResources().getDrawable(resource); view.setBackgroundDrawable(d); view.setLayoutParams(new LinearLayout.LayoutParams(d.getIntrinsicWidth(), d.getIntrinsicHeight())); layout.addView(view); }
private void addNinePatchResourceDrawable(LinearLayout layout, int resource) { View view = new View(this); final Drawable d = getResources().getDrawable(resource); view.setBackgroundDrawable(d); Log.i("foo", "9-patch #" + Integer.toHexString(resource) + " w=" + d.getIntrinsicWidth() + " h=" + d.getIntrinsicHeight()); view.setLayoutParams(new LinearLayout.LayoutParams( d.getIntrinsicWidth()*2, d.getIntrinsicHeight()*2)); layout.addView(view); }
private void addResourceDrawable(LinearLayout layout, int resource) { View view = new View(this); final Drawable d = getResources().getDrawable(resource); view.setBackgroundDrawable(d); view.setLayoutParams(new LinearLayout.LayoutParams(d.getIntrinsicWidth(), d.getIntrinsicHeight())); layout.addView(view); }
private void addNinePatchResourceDrawable(LinearLayout layout, int resource) { View view = new View(this); final Drawable d = getResources().getDrawable(resource); view.setBackgroundDrawable(d); Log.i("foo", "9-patch #" + Integer.toHexString(resource) + " w=" + d.getIntrinsicWidth() + " h=" + d.getIntrinsicHeight()); view.setLayoutParams(new LinearLayout.LayoutParams( d.getIntrinsicWidth()*2, d.getIntrinsicHeight()*2)); layout.addView(view); }
private void addBitmapDrawable(LinearLayout layout, int resource, boolean scale) { Bitmap bitmap; bitmap = loadAndPrintDpi(resource, scale); View view = new View(this); final BitmapDrawable d = new BitmapDrawable(getResources(), bitmap); if (!scale) d.setTargetDensity(getResources().getDisplayMetrics()); view.setBackgroundDrawable(d); view.setLayoutParams(new LinearLayout.LayoutParams(d.getIntrinsicWidth(), d.getIntrinsicHeight())); layout.addView(view); }
private void addBitmapDrawable(LinearLayout layout, int resource, boolean scale) { Bitmap bitmap; bitmap = loadAndPrintDpi(resource, scale); View view = new View(this); final BitmapDrawable d = new BitmapDrawable(getResources(), bitmap); if (!scale) d.setTargetDensity(getResources().getDisplayMetrics()); view.setBackgroundDrawable(d); view.setLayoutParams(new LinearLayout.LayoutParams(d.getIntrinsicWidth(), d.getIntrinsicHeight())); layout.addView(view); }