I resolved the problem.  For anyone else who might run into this
issue, the answer is that your in your custom ViewGroup, you need to
ensure that the measureChildren method is called within your onMeasure
routine.  In addition, all of the child windows need to have a valid
ViewGroup.LayoutParams set which specify the correct with and height
of the control.  Without this, the TextView (and possibly other
controls) will not handle the alignment options correctly.

On May 27, 2:14 pm, John Gaby <jg...@gabysoft.com> wrote:
> I have a TextView control which is being placed in a custom ViewGroup
> which places the control at a certain position and size.  I want to
> center the text vertically within that control.  I am making the call:
>
> tv.setGravity(Gravity.CENTER_VERTICAL);
>
> but the text still remains aligned to the top of the TextView box
> (note that if I set it to be centered horizontally, that works).
>
> Now if I take that same TextView and simply set it as the main view
> (e.g. setContentView(tv)), the vertical centering works fine.  Is
> there something that my custom ViewGroup must do to get the vertical
> centering to work?
>
> Thanks.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to