1

The ImageView fills with black color after setting an image.

I'm setting image with this line

  super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    Root = findViewById(R.id.Iv);

    sensorManager = (SensorManager) getSystemService(Service.SENSOR_SERVICE);
    Proximity = sensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY);

    //Root.setBackgroundColor(Color.MAGENTA);
   Root.setImageResource(R.drawable.a);
}

Please Help!

2 Answers2

0

Please try with this

  Context mContext = this;
  Root.setImageDrawable(mContext.getResources().getDrawable(R.drawable.a));
Flying Dutchman
  • 365
  • 6
  • 13
0

As mobile screen comes with different sizes, so may be your image resolution is high or not compatible to the width & height of ImageView. Try to decrease the size of image so that it loads on Runtime also.

maazakn
  • 384
  • 2
  • 10