android zoom in button only with webview - android

I have a simple android webview app and I want to add zoom in button only,
I added the zoom in button in the graphical layout:
but how can I make it work in the java file ?

In your activity, add an on click listener to your button that zooms in the webview:
findViewById(R.id.zoom_in_btn).setOnClickListener(
new View.OnClickListener() {
#Override
public void onClick(View v)
{
webviewer.zoomIn();
}
});

Related

AchartEngine disable only zoomout button

I'm using AchartEngine to draw graphs,
is it possible to disable only the zoom out button ?
thanks.
You can disable the original zoom buttons with below code
mRenderer.setZoomButtonsVisible(false);
and write your own button just to zoom-in inside your xml file and do something like below:
ImageButton btnZoomIn= (ImageButton) findViewById(R.id.btnZoomIn);
btnZoomIn.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
mChartView.zoomIn();
}
});

my activity consist of one activity and many hidden layouts. on different button click respective layouts are set to visible

Now my question is this, is there any way to apply any default animation when each of the layout is set to visible? Instead of appearing all of a sudden, any sliding animation would look sleek.
//to show home page
homeButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
liMenu.setVisibility(View.VISIBLE);
}
});
//to show .net page
dotnetButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
liDotnet.setVisibility(View.VISIBLE);
}
});

Change zoom controls in a MapView

I would like to change the predefined style of the zoom controls in my application to appear like the new zoom controls in the google maps application. See below:
How can I do it? I have been looking around and I haven't found anything.
Thanks in advance.
You should have four image drawables namely:
Zoom in (+) enable/disable
Zoom out (-) enable/disable
Put them in MapView layout an ImageView or Button with background image as the above drawables.
Then you should assign onClickListeners like:
zoomIn.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
mapView.getController.zoomIn()
checkzoom();
}
});
zoomOut.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
mapView.getController.zoomOut()
checkzoom();
}
});
public void checkzoom() {
if(mapView.getZoomLevel()==1) // dont know if 0 or 1, just wrote it
{
zoomOut.setEnabled(false);
// or u can change drawable and disable click
}
if(mapView.getZoomLevel()==18) {
zoomIn.setEnabled(false);
// or u can change drawable and disable click
}
}
EDIT:
I solved the problem this way: disabled built in zoom controls (setBuiltInZoomControls(false)), added my own buttons to UI and added handlers for click on button events.

change button image in android

I want to change the image of a button in my code. I found this can be done in xml:
please check this link
but the image will not stay on after I released the button. I want to click the button
and the button change to a new image. Can this be done?
in onClick method you need to change the Button's image, this way..
public void onClick(View v) {
if(v==buttonName){
buttonName.setBackgroundResource(R.drawable.imageName);
}
}
Assuming an ImageButton...
You can change the background image in an onClick listener, similar to the following:
myButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
//set button image
myButton.setImageBitmap(myBitmapFile)
}
});

Always show zoom controls on a MapView

Is there a way to always show the zoom controls on a MapView? I have added the zoom controls using
map=(MapView)findViewById(R.id.map);
map.setBuiltInZoomControls(true);
but the zoom controls fade in and out. I want them to always be visible.
Solved this by putting my own ZoomControls in my layout xml:
<ZoomControls android:id="#+id/zoomcontrols"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
and then setting up onClickListeners for then to handle the zoom:
zoomControls = (ZoomControls) findViewById(R.id.zoomcontrols);
zoomControls.setOnZoomInClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
mapController.zoomIn();
}
});
zoomControls.setOnZoomOutClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
mapController.zoomOut();
}
});
Intrications' solution does work, but you lose the built in functionality where the button disables when you have zoomed in or out all the way. You can retain this functionality by using the following instead:
localMapView.getZoomButtonsController().setAutoDismissed(false);
However, this does not let you place the controls wherer you want in the panel, and although it does not go away, it does not show up the first time until the user touches the screen once. I tried calling setVisible(true) on the controller, but that does not seem to work for some reason.

Categories

Resources