1. geraldinejns's Avatar
    I am using at this time the zoomControls to zoom in and out. Instead of using zoomControl from the palette, I want to be able to use my fingers. How can i write code for this. Or what does the code look like for this.

    MainActivity code below

    package com.example.geral_000.myapplication;

    import android.os.Bundle;
    import android.support.v7.app.AppCompatActivity;
    import android.view.View;
    import android.widget.ImageView;
    import android.widget.ZoomControls;

    public class MainActivity extends AppCompatActivity {

    ZoomControls zoomIt;
    ImageView image;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    zoomIt = (ZoomControls) findViewById(R.id.zoomControls);
    image = (ImageView) findViewById(R.id.imageView);

    zoomIt.setOnZoomInClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
    float x = image.getScaleX();
    float y = image.getScaleY();

    image.setScaleX((int) (x+1));
    image.setScaleY((int) (y+1));}
    });

    zoomIt.setOnZoomInClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {

    float x = image.getScaleX();
    float y = image.getScaleY();

    image.setScaleX((int) (x-1));
    image.setScaleY((int) (y-1));
    }
    });
    }

    }

    activity_main below

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    androidaddingBottom="@dimen/activity_vertical_margin"
    androidaddingLeft="@dimen/activity_horizontal_margin"
    androidaddingRight="@dimen/activity_horizontal_margin"
    androidaddingTop="@dimen/activity_vertical_margin"
    tools:context="com.example.geral_000.myapplication.MainActivity">

    <TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Hello World!"
    android:id="@+id/textView" />

    <ZoomControls
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/zoomControls"
    android:layout_alignParentBottom="true"
    android:layout_alignParentRight="true"
    android:layout_alignParentEnd="true" />

    <ImageView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/imageView"
    android:src="@drawable/give_back"
    android:layout_centerVertical="true"
    android:layout_toRightOf="@+id/textView"
    android:layout_toEndOf="@+id/textView"
    android:focusableInTouchMode="false" />
    </RelativeLayout>

    the code above works fine, but i want to be able to use my forefinger and thumb.
    09-17-2016 06:48 PM
  2. ManiacJoe's Avatar
    You will probably get more quality responses over in the Developers forum
    Android Developers - Android Forums at AndroidCentral.com
    09-17-2016 08:29 PM
  3. geraldinejns's Avatar
    Thank you.
    09-18-2016 03:46 PM

Similar Threads

  1. Replies: 13
    Last Post: 10-02-2018, 01:11 AM
  2. Replies: 4
    Last Post: 09-17-2016, 09:18 PM
  3. Replies: 1
    Last Post: 09-17-2016, 08:57 PM
  4. New Note4 in the House!
    By rtwright68 in forum Samsung Galaxy Note 4
    Replies: 3
    Last Post: 09-17-2016, 08:10 PM
  5. Replies: 1
    Last Post: 09-17-2016, 06:41 PM
LINK TO POST COPIED TO CLIPBOARD