android - Drawing a graph, can not see the resulting image -


i trying draw graph in android. want graph scale current screen size, instead of setting them explicitly in constants, size of linearlayout intended contain graph. however, there problem it's not possible sizes in activity's oncreate(), use custom linearlayout overridden onsizechanged(). include layout with:

view class="com.nnevod.loggraph.graph$graphdisplaylayout"     android:layout_height="fill_parent"     android:id="@+id/linearlayout1"     android:layout_width="fill_parent"     android:layout_weight="1"     android:background="@color/white" 

i've omitted angular brackets.

in overridden onsizechanged(), dimensions of view read, done described in many graphing examples: bitmap created, passed graph-drawing class, imageview created, set bitmap, , added custom linearlayout.

problem is, graph's image not visible. however, if try inspect hierarchyviewer, image becomes visible. if cut-paste code onsizechanged() activity's oncreate(), sans using preset dimensions instead of measured ones, displayed nicely.

so, question i'm doing wrong? i've had assumptions either i'm using wrong context in custom onsizechanged(), or not possible update view there, , should somehow pass measured dimensions activity , attachment of bitmap in of activity's methods. though on context part, i've tried using available contexts, including using activity's context, no avail.

if needed, i'll provide more code.

i had similar problem once, , told hierarchy viewer requestlayout(). so, told, forgot call somewhere, don't think did. later i've found similar situation reported bug, being workaround finding way call requestlayout() somewhere.

it strange because @ conditions thing worked (adding random view here , there, or updating drawing). anyway, @ end preferred creating custom view directly drew needed (and drawing happens after onmeasure, there's no problem in making adaptive drawing).

(funny it's again graphs!)

references (1) , (2).


Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -