5

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.

BenMorel
  • 34,448
  • 50
  • 182
  • 322
adek
  • 3,045
  • 2
  • 27
  • 41

2 Answers2

1

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

Community
  • 1
  • 1
toni
  • 361
  • 7
  • 19
  • Thanks. I've just did it today. In the same way :) I don't have this issue. Or I'm testing it wrong. – adek Feb 07 '12 at 22:13
  • @adek do you use relative layout or linear layout for holder of the graph. Can you paste the whole xml? Thanks, Toni – toni Feb 09 '12 at 06:28
  • This is my XML: ` #my buttons ` – adek Feb 09 '12 at 18:36
  • Hi. I tryed Button with background and it is working. When button is passsive - doesn't have the onRollOver graphics all is OK. But if button is changing view on rollover it is acting the same way... Strange... Thank you @adek. – toni Feb 10 '12 at 05:53
1

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>
animuson
  • 53,861
  • 28
  • 137
  • 147
adek
  • 3,045
  • 2
  • 27
  • 41