Is there a way to change ImageView drawable with its corresponding drawable for landscape mode without destroying the whole activity. I tried to set the drawable again in onConfigurationChanged callback but it doesn't work. Something like this
@Override
public void onConfigurationChanged(Configuration conf) {
super.onConfigurationChanged(conf);
mImageView.setImageDrawable(getResources().getDrawable(R.drawable.iv));
}
When i star the activity in landscape mode to correct drawable is displayed so resources are located correctly.
In your sample project just replace
iv.setBackgroundResource(R.drawable.android);
with
iv.setImageDrawable(getResources().getDrawable(R.drawable.android));
I guess setBackgroundResource does nothing because the same resource is already assigned to ImageView.
Take a look at this
http://open-pim.com/tmp/ImageTest.zip
I tried your approach and it works just great for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With