List of usage examples for android.widget ImageView getRootView
public View getRootView()
Finds the topmost view in the current view hierarchy.
From source file:com.nextgis.maplibui.fragment.CompassFragment.java
private void loadImage(ImageView view, String image) { int width = 0, height = 0; if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) width = view.getRootView().getMeasuredWidth(); else//from www . j a va2 s . c om height = view.getRootView().getMeasuredHeight(); InputStream is = null; try { is = getContext().getAssets().open(image); BitmapFactory.Options options = ControlHelper.getOptions(is, width, height); is = getContext().getAssets().open(image); Bitmap bitmap = ControlHelper.getBitmap(is, options); view.setImageBitmap(bitmap); } catch (IOException e) { e.printStackTrace(); } }