Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8066451
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T11:59:55+00:00 2026-06-05T11:59:55+00:00

I have one activity which is having linear layout and inside this layout there

  • 0

I have one activity which is having linear layout and inside this layout there are several linear layouts and each linear layout is having set if buttons and text views. I want to achieve multi touch feature for whole screen means if user perform zoom in-zoom out using his finger then it should zoom in and zoom out whole screen(increase and decrease all buttons,text views size accordingly once).

How to achieve it using android 2.1?

regards,
Piks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T11:59:57+00:00Added an answer on June 5, 2026 at 11:59 am

    This might give you an idea:

    import java.util.ArrayList;
    import android.content.Context;
    import android.graphics.Canvas;
    import android.graphics.Color;
    import android.graphics.DashPathEffect;
    import android.graphics.Paint;
    import android.graphics.PointF;
    import android.util.AttributeSet;
    //import android.util.FloatMath;
    import android.view.MotionEvent;
    import android.view.View;
    
    public class MultitouchView extends View {
        private static final int STROKE_WIDTH = 1;
        private static final int CIRCLE_RADIUS = 20;
    
        private ArrayList<PointF> touchPoints = null;
        private Paint drawingPaint = null;
        private boolean isMultiTouch = false;
        private int pathEffectPhase = 0;
    
        public MultitouchView(Context context) {
            super(context);
    
            initialize(context);
        }
    
        public MultitouchView(Context context, AttributeSet attrs, int defStyle) {
            super(context, attrs, defStyle);
    
            initialize(context);
        }
    
        public MultitouchView(Context context, AttributeSet attrs) {
            super(context, attrs);
    
            initialize(context);
        }
    
        @Override
        protected void onDraw(Canvas canvas) {
            super.onDraw(canvas);
    
            if(touchPoints.size() > 0)
            {
                DashPathEffect effect = new DashPathEffect(new float[] {7,7}, pathEffectPhase);
                PointF midpt = null;
    
                drawingPaint.setPathEffect(effect);
    
                for(int index=1; index<touchPoints.size(); ++index)
                {
                    midpt = getMidPoint(
                            touchPoints.get(index - 1).x,touchPoints.get(index - 1).y,
                            touchPoints.get(index).x,touchPoints.get(index).y);
    
                    canvas.drawCircle(
                            touchPoints.get(index - 1).x,touchPoints.get(index - 1).y, 
                            1, drawingPaint);
                    canvas.drawCircle(
                            touchPoints.get(index - 1).x,touchPoints.get(index - 1).y, 
                            CIRCLE_RADIUS, drawingPaint);
    
                    canvas.drawCircle(touchPoints.get(index).x,touchPoints.get(index).y, 
                            1, drawingPaint);
                    canvas.drawCircle(touchPoints.get(index).x,touchPoints.get(index).y, 
                            CIRCLE_RADIUS, drawingPaint);
    
                    canvas.drawLine(
                            touchPoints.get(index - 1).x,touchPoints.get(index - 1).y,
                            touchPoints.get(index).x,touchPoints.get(index).y,
                            drawingPaint);
    
                    canvas.drawCircle(midpt.x,midpt.y, 10, drawingPaint);
                }
    
                ++pathEffectPhase;
    
                invalidate();
            }
        }
    
        @Override
        public boolean onTouchEvent(MotionEvent event) {
            super.onTouchEvent(event);
    
            int action = event.getAction() & MotionEvent.ACTION_MASK;
    
            switch(action)
            {
                case MotionEvent.ACTION_DOWN:
                {
                    invalidate();
    
                    break;
                }
                case MotionEvent.ACTION_POINTER_DOWN:
                {
                    isMultiTouch = true;
    
                    setPoints(event);
                    invalidate();
    
                    break;
                }
                case MotionEvent.ACTION_POINTER_UP:
                {
                    isMultiTouch = false;
    
                    break;
                }
                case MotionEvent.ACTION_MOVE:
                {
                    if(isMultiTouch)
                    {
                        setPoints(event);
                        invalidate();
                    }
    
                    break;
                }
            }
    
            return true;
        }   
    
        private void initialize(Context context){
            drawingPaint = new Paint();
    
            drawingPaint.setColor(Color.RED);
            drawingPaint.setStrokeWidth(STROKE_WIDTH);
            drawingPaint.setStyle(Paint.Style.STROKE);
            drawingPaint.setAntiAlias(true);
    
            touchPoints = new ArrayList<PointF>();
        }
    
        public void setPoints(MotionEvent event){
            touchPoints.clear();
    
            int pointerIndex = 0;
    
            for(int index=0; index<event.getPointerCount(); ++index)
            {
                pointerIndex = event.getPointerId(index);
    
                touchPoints.add(new PointF(event.getX(pointerIndex),event.getY(pointerIndex)));
            }
        }
    
        private PointF getMidPoint(float x1,float y1, float x2, float y2) {
            PointF point = new PointF();
    
            float x = x1 + x2;
            float y = y1 + y2;
    
            point.set(x / 2, y / 2);
    
            return point;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have one activity in which I am having one TabHost with two tabs.
i have main activity in which i have Four menus. and i have one
I have a design of activities like this I have one main activity and
I have one SubjectTabActivity and i need to show listview on this activity. But
I have an ArrayList of objects in one activity and I need this arrayList
I have one class called Global and two other activities. In each activity I
I am using fragments to show images/pages.I have one Activity(Main) which contains all the
I am working on activity which request one php file on server & this
I am trying to display ListView . I have created one activity , in
Within one Activity I have th following piece of code: public void onStartMonitoringToggleClicked(View v)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.