Android : adjustViewBounds for an imageview during onConfigurationChanged

on Saturday, December 13, 2014


I have a simple requirement, wherein I would like the imageView to readjust the bounds when onConfigurationChanged is triggered. So far it seems that imageView does not re-adjust the bounds correctly.


Let me explain what I am trying to do



+-------------------A----------------------+
| +-----------------B--------------------+ |
| | +-----------------C/D--------------+ | |
| | | | | |
| | +----------------------------------+ | |
| +--------------------------------------+ |
+------------------------------------------+


A - is FrameLayout B - is a RelativeLayout C - ImageView D - An overlay view


A/B constraints -> MATCH_PARENT, MATCH_PARENT C constraints -> MATCH_PARENT, WRAP_CONTENT, adjustViewBounds = true


I want C to be adjusted in the center of B, and still cover the maximum possible region. D is an overlay view to be drawn on top of C, having exact same bounds as C.


There are other UI components which are not important to this question though.


Summarize,


So I want to be able to always get B/C/D of the same size, in the center of A, such that C covers maximum region.


Question


The above constraints seem to work for the first time, but do not work when I override configChanges. Any idea on how to solve this?


0 comments:

Post a Comment