Android set height and width of Custom view programmatically -


i have created custom view named graphview . here structure graphview class.

public class graphview extends view {      public graphview(context context, float[] values, string title, string[] horlabels, string[] verlabels, boolean type) {         super(context);                 ........    }     ..................    ................. } 

i have added view in tablerow using addview(). working fine. want set height , width graphview. how that?

the easy way set size programatically :

graphview.setlayoutparams(new layoutparams(width, height)); 

this fine if know exact size of view. however, if want more flexible approach, can override onmeasure() method measure view more precisely depending on space available , layout constraints (wrap_content, match_parent, or fixed size).

you can find example on how override onmeasure() looking @ android docs , labelview sample in sdk directory.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -