Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

achartengine custom zoom buttons

Is there an easy way to use custom images for Zoom Buttons? I'd like to use default setZoomButtonsVisible functions to manage show/hide buttons.

How can I override those buttons?

I'd like to use icons from my res/drawable (drawable-hdpi, drawable-ldpi ..) to make sure images will be good looking on all screens.

like image 510
adek Avatar asked Nov 04 '22 06:11

adek


2 Answers

You can hide original zoom buttons and enable external zoom:

private XYMultipleSeriesRenderer mRenderer; //or any of other renderer
mRenderer.setZoomButtonsVisible(false);
mRenderer.setExternalZoomEnabled(true);

//then add click events tot he imagebuttons on the view
//mChartView --> private GraphicalView mChartView;

    ImageButton btnZoomIn= (ImageButton) findViewById(R.id.btnZoomIn);

    btnZoomIn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mChartView.zoomIn();

            }
    });

    ImageButton  btnZoomOut = (ImageButton) findViewById(R.id.btnZoomOut );

    btnZoomOut.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mChartView.zoomOut();
            }
    });

Hope it helps.

The only problem is that some strange think is happening on the click. I posted problem here and also as an issue.

Hope somebody will find an answer.

Toni

like image 157
toni Avatar answered Nov 11 '22 06:11

toni


I'm using almost the same way I think. I've got:

renderer.setZoomEnabled(true);
renderer.setExternalZoomEnabled(true);
renderer.setApplyBackgroundColor(true);

And I'm using .xml file for my buttons layout. I'm not using <ImageButton> in my code. I'm using <Button> with background. And in this way these buttons are images. My code for button:

<Button
                    android:id="@+id/zoomin"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="bottom"
                    android:background="@drawable/action_zoomin"
                    android:hapticFeedbackEnabled="true"
                    android:layout_marginRight="15dp">
  </Button>
like image 41
adek Avatar answered Nov 11 '22 06:11

adek