Change the background color of XYplot in android to white?

允我心安 提交于 2019-12-24 03:07:27

问题


This my XML file I want to change the background color of this XY plot in android to White? I tried some code but it's not changing.

<?xml version="1.0" encoding="utf-8"?>
  <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/scrollView1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >

 <LinearLayout
    android:id="@+id/LinearLayout"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    android:paddingTop="50dp" >

<TextView
    android:id="@+id/values"
    android:layout_width="264dp"
    android:layout_height="34dp"
    android:layout_weight="0.57"
    android:hint="heart  beat values"
    android:paddingBottom="90dp"
    android:textSize="20sp" />

<com.Android.XYPlot
    android:id="@+id/dynamicPlot"
    android:layout_width="fill_parent"
    android:layout_height="230dp"
    android:layout_marginLeft="10dp"
    android:layout_marginRight="10dp"
    android:layout_marginTop="10dp"
    android:background="@drawable/ic_launcher"
    android:paddingBottom="5dp" />
</LinearLayout>

</ScrollView>

I tried these thing to change my background color but it's not working.

     dynamicPlot.setBackgroundColor(getResources().getColor(Color.WHITE));

And if it's possible I want to remove the grids in the background also..

   dynamicPlot.getLayoutManager().remove(dynamicPlot.getLegendWidget());

I tried this one for removing grid lines but not working.

So help me please..

Is it possible to change the background color? I am plotting line graph and I am able to change the color of lines in the graph.But how to change the background? is it default color?


回答1:


      dynamicPlot.getGraphWidget().getDomainGridLinePaint().setColor(Color.TRANSPARENT);
           //set all domain lines to transperent

      dynamicPlot.getGraphWidget().getRangeSubGridLinePaint().setColor(Color.TRANSPARENT);
          //set all range lines to transperent  

      dynamicPlot.getGraphWidget().getRangeGridLinePaint().setColor(Color.TRANSPARENT);
         //set all sub range lines to transperent 

      dynamicPlot.getGraphWidget().getDomainSubGridLinePaint().setColor(Color.TRANSPARENT);
        //set all sub domain lines to transperent


      dynamicPlot.getGraphWidget().getGridBackgroundPaint().setColor(Color.WHITE);
       //set background to white to transperent


来源:https://stackoverflow.com/questions/19993725/change-the-background-color-of-xyplot-in-android-to-white

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!