achartengine custom zoom buttons

拈花ヽ惹草 提交于 2019-12-04 08:16:11
toni

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

adek

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