I have a relative layout that has an ImageView and and a textview aligned to right of the ImageView.
I have a class that inflates this relative layout and adds in itself (as if it is that layout).
Initially textview's visiblity is set to GONE, hence the size of the view is just that of the ImageView. Now, when the view receives focus, I set the visibility of textview to VISIBLE and set an animation to incrementally resize the view from imageView's width to (approximately)imageview+textview width (I am actually giving hard coded value in the program).
My question is, how can i determine the total width of the layout after i have enabled/diabled the visibility of the textview(since textview's width can be variable), so that i can specify that value to the animation as the final endpoint?
I had like to find this out right after i set the visiblity because if there is a delay in enabling the visiblity and starting the animation, the output is like the view with complete width (imageview+textview) is displayed first, then goes back to imageview size(start of animation), and then goes on to imageview+textview size(end of animation). If these is no way to find it out at that time, then can anyone please suggesst me to manually calculate what the final size could be?
----EDIT----
For the effect I wanted to achieve, there didn't seem to be any way. Final dimension of a view can be computed only after layout for that view is done by Android. The final dimension cannot be computed right after you enable the visiblity of a child view
Hence for my solution, I kept the parent layout (Relative layout) set to fill_parent for the width, had another child layout (background) whose size I could control through program, and then on top of this I have my imageView (Parent Left aligned) + textView (right of imageView, fill_parent).
So when the view is created for the first time, parent layout is always fill_parent, background layout has size of the imageview only and set textview's visiblity to invisible. And when a text is added to the text view, few milliseconds later (Using countdowntimer), I fetched the final dimension, set the animation to scale the size from imageView's width to imageView+textView width, and after end of animation set the visiblity of text view to visible.
Am not sure if my solution is the best but it seems to work properly without any glitches.