Search code examples
androidbitmapandroidplot

androidplot: insert logo on graph


I would like to add a logo, or generally one or more bitmap,on androidplot graph. I think the solution is to transform the androidplot graph as a bitmap and then add the other bitmap above. But this solution is not good because convert the graph into bitmap i lose the quality of the graph. The ideal would be not convert into bitmap. can someone help me? thanks


Solution

  • Use FrameLayout for this purpose,

    Add your graph xml code in FrameLayout and Add another ImageView or Button or what ever you like in FrameLayout

    I am placing an ImageView in the bottom right corner of the Graph. You can change it.

    1. XML Code:

      <FrameLayout
              android:id="@+id/frame_for_graph"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent" >
      
              <com.androidplot.xy.XYPlot
                      android:id="@+id/mySimpleXYPlot"
                      android:layout_width="fill_parent"
                      android:layout_height="fill_parent"
                      title="Stats" />
      
              <ImageView
                      android:id="@+id/iv_Logo"
                      android:layout_width="40dp"
                      android:layout_height="40dp"
                      android:layout_marginBottom="20dp"
                      android:layout_gravity="right|bottom"
                      android:src="@drawable/ic_launcher" />
      </FrameLayout>
      
    2. Java Code for Logo:

      ImageView logo = (ImageView) findViewById(R.id.iv_Logo);
      
      logo.setOnClickListener(new OnClickListener() {
      
          @Override
          public void onClick(View arg0) {
              // TODO Auto-generated method stub
              Toast.makeText(getApplicationContext(), "Logo Clicked",
                      Toast.LENGTH_LONG).show();
              //Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("YOUR COMPANY URL"));
              //startActivity(browserIntent);
          }
      });
      

    SnapShot:

    Snap