[android-developers] Re: TextView with a top margin that is proportional to the height of the parent view
Yes, but you'll have to do it at runtime as there is not a way to do
proportional layout as you describe in xml. To prevent a visible
transition from the xml size to the correct size, you'll probably want
to extend LinearLayout and override its onLayout(). You'll want to
layout your child textview within that and you'll want to use
getHeight() to get the height of the LinearLayout at runtime. I'd
suggest looking through the code of ListView or RelativeLayout to see
how children are measured and layout.
The other option would be to do this after everything is inflated. You
can override onFinishInflate of the LinearLayout and then adjust the
height of the TextView from there. You'll need to invalidate the
TextView after adjusting it's height.
Jonathan
On Jan 28, 9:48 pm, John Gaby <jg...@gabysoft.com> wrote:
> Is there a way to position text within a linear layout such that the
> position of the text is proportional to the height, rather than a
> fixed distance. For example, I would like the text to be displayed
> down from the top a distance equal to 20% of the height of the view.
>
> 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+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home