2013-12-31 1 views
1

androidplot의 범례 위젯을 원하는 곳으로 이동하는 데 어려움을 겪고 있습니다.androidplot에서 범례 위젯의 배치를 변경하는 방법

androidplot을 사용하여 데이터 집합을 렌더링하려고합니다. DemoApp에서 사용 된 position() 메서드를 호출하여 범례 위젯을 점으로 배치하는 방법을 따랐습니다. 그러나 결코 성공하지 못했습니다. 나는 거의 1 주 동안 이것에 의해 막혔다. 누군가 내 코드에서 실수를했는지 확인할 수 있도록 도와 줄 수 있습니까? 예제 코드를 제외하고이 lib를 사용하는 방법에 대한 문서를 찾지 못했습니다.

내 레이아웃 XML :

<com.androidplot.xy.XYPlot 
    android:id="@+id/mySimpleXYPlot" 
    android:layout_width="fill_parent" 
    android:layout_height="200dp" 
    android:layout_below="@+id/seperator1" 
    androidPlot.domainLabelWidget.labelPaint.textSize="@dimen/domain_label_font_size" 
    androidPlot.graphWidget.domainLabelPaint.textSize="@dimen/domain_tick_label_font_size" 
     androidPlot.graphWidget.domainOriginLabelPaint.textSize="@dimen/domain_tick_label_font_size" 
     androidPlot.graphWidget.rangeLabelPaint.textSize="@dimen/range_tick_label_font_size" 
     androidPlot.graphWidget.rangeOriginLabelPaint.textSize="@dimen/range_tick_label_font_size" 
     androidPlot.legendWidget.heightMetric.value="25dp" 
     androidPlot.graphWidget.marginBottom="25dp" 
     androidPlot.graphWidget.marginLeft="15dp" 
     androidPlot.graphWidget.marginRight="10dp" 
     androidPlot.graphWidget.marginTop="20dp" 
     androidPlot.legendWidget.iconSizeMetrics.heightMetric.value="15dp" 
     androidPlot.legendWidget.iconSizeMetrics.widthMetric.value="15dp" 
     androidPlot.legendWidget.positionMetrics.anchor="left_top" 
     androidPlot.legendWidget.positionMetrics.xPositionMetric.value="0" 
     androidPlot.legendWidget.textPaint.textSize="@dimen/legend_text_font_size" 
     androidPlot.legendWidget.widthMetric.value="100dp" 
     androidPlot.rangeLabelWidget.labelPaint.textSize="@dimen/range_label_font_size" 
     androidPlot.titleWidget.labelPaint.textSize="@dimen/title_font_size" /> 
    <!-- androidPlot.graphWidget.gridLinePaint.color="#000000"/> --> 

내 소스 코드 :

private void makePlotPretty() { 
      // use a 2x2 grid with room for 4 items: 
      plot.getLegendWidget().setTableModel(new DynamicTableModel(2, 2)); 

      // add a semi-transparent black background to the legend 
      // so it's easier to see overlaid on top of our plot: 
      Paint bgPaint = new Paint(); 
      bgPaint.setColor(Color.BLACK); 
      bgPaint.setStyle(Paint.Style.FILL); 
      bgPaint.setAlpha(255); 

      plot.getLegendWidget().setBackgroundPaint(bgPaint); 

/*   plot.getLegendWidget().setPositionMetrics(null); 
*/ 

      plot.getLegendWidget().setWidth(PixelUtils.dpToPix(40), SizeLayoutType.FILL); 

      plot.getGraphWidget().setRangeLabelHorizontalOffset(-1); 

      plot.getLegendWidget().position(125, XLayoutStyle.ABSOLUTE_FROM_LEFT, 100, YLayoutStyle.ABSOLUTE_FROM_TOP, AnchorPosition.LEFT_TOP); 

     } 
+0

[범례 문서 (http://androidplot.com/docs/customizing-the-legend/) – Ifor

답변

1

있다 documentation 전설의 위치를 ​​포함하여 샘플 코드와 page for the legend 포함.

임계 선 난이 정의는 더 이상 유효하지 않은 것으로 확인 된 코드

 mySimpleXYPlot.position(
      mySimpleXYPlot.getLegendWidget(), 
      20, 
      XLayoutStyle.ABSOLUTE_FROM_RIGHT, 
      35, 
      YLayoutStyle.ABSOLUTE_FROM_BOTTOM, 
      AnchorPosition.RIGHT_BOTTOM); 
+3

것으로 보인다 . 올바른 호출은 다음과 같아야합니다. mySimpleXYPlot.getLegendWidget(). position(). 오늘, 나는이 함수를 onCreate()에 넣으려고했다. 그런 다음 전설은 내가 원하는 곳으로 옮길 수 있습니다. 위치가 onCreate()에서만 설정 될 수 있는지 궁금합니다. – ping