Anandhu
Anandhu

Reputation: 312

Change the background color of XYplot in android to white?

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?

Upvotes: 2

Views: 1611

Answers (1)

Anandhu
Anandhu

Reputation: 312

      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

Upvotes: 2

Related Questions