jeudi 19 juin 2014

Basing a custom View's width off of its height


Vote count:

0




I have a custom View I'm making which has a fixed proportion between width and height. I want the programmer to set the height and I would like the View to set its own width according to a formula based on height.


The View is going to be a child of a RelativeLayout so I can't use the height of the parent element to calculate anything.


How can I accomplish this? I don't know how to do it in the onMeasure hook because the control's width and height are not available at that time.


By the way, I am making this view solely programmatically, no XML involved.



asked 36 secs ago






Aucun commentaire:

Enregistrer un commentaire