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.
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
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With