achartengine custom zoom buttons

偶尔善良 提交于 2019-12-21 17:06:29

问题


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.


回答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




回答2:


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>


来源:https://stackoverflow.com/questions/9142212/achartengine-custom-zoom-buttons

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