Example usage for android.widget ImageView getRootView

List of usage examples for android.widget ImageView getRootView

Introduction

In this page you can find the example usage for android.widget ImageView getRootView.

Prototype

public View getRootView() 

Source Link

Document

Finds the topmost view in the current view hierarchy.

Usage

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();
    }
}