1

I use the following code to set the size of my graph area. I have done some searching but I haven't found a way to add this in the XML.

    // Set size of graph area (not plot area)
    final Size sm = new Size(900, SizeLayoutType.ABSOLUTE, 900, SizeLayoutType.ABSOLUTE);
    myPositionLines.getGraphWidget().setSize(sm);

How can I do this in the XML file as per the legend i.e. something like this:

ap:legendHeight="40dp"

Thanks

Osama Aftab
  • 1,161
  • 9
  • 15
puzii
  • 117
  • 7

1 Answers1

1

(Updated) As of Androidplot v0.9.7 there are now styleable attrs for controlling the size and positioning of the graph widget from XML.

Keep in mind though that because the graph is a widget component, the sizing / positioning conventions follow those of all other Androidplot widgets. Check out the "x/y positioning widgets" and "sizing widgets" sections of this doc for info on how that works.

Here are the xml attrs currently available:

<attr name="graphHeightSizeLayoutType"/>
<attr name="graphWidthSizeLayoutType"/>
<attr name="graphHeight" format="dimension|float|integer"/>
<attr name="graphWidth" format="dimension|float|integer"/>
<attr name="graphLayoutStyleX"/>
<attr name="graphLayoutStyleY"/>
<attr name="graphPositionX" format="dimension|float|integer"/>
<attr name="graphPositionY" format="dimension|float|integer"/>
<attr name="graphAnchorPosition"/>

So for example, adding the following to your plot's xml element would give your graph a width of 300dp:

ap:graphWidthSizeLayoutType="absolute"
ap:graphWidth="300dp"
Nick
  • 8,181
  • 4
  • 38
  • 63
  • Great thanks Nick. I will give this a go. I wanted something like this so I could have this code in the XML, so that I can follow Android's way of catering for different screen sizes! – puzii May 05 '16 at 10:42
  • I have just tried this with: ap:graphHeightSizeLayoutType="absolute" ap:graphHeight="300dp" ap:graphWidthSizeLayoutType="absolute" ap:graphWidth="300dp" But it does not seem to work. The width seems to work but the height doesn't. – puzii May 05 '16 at 11:34
  • Confirmed - there's a bug in how the style is applied. 0.9.8 contains the fix and will be available no later than 5/6/2016. – Nick May 05 '16 at 14:46
  • ^ 0.9.8 is now available. – Nick May 06 '16 at 21:56
  • Thanks Nick. Initial testing showing it is working fine! Appreciated. – puzii May 07 '16 at 11:57
  • I am unable to do styling using xml cmd ap:graphWidthSizeLayoutType="absolute" ap:graphWidth="300dp". I used com.androidplot:androidplot-core:0.9.8 library – Pranita Patil Jun 09 '16 at 12:10