Page 118

Android Programming Cookbook

110 / 143

android:layout_width="match_parent" android:layout_height="match_parent"> <TextView android:id="@+id/status" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center" android:text="@string/noActionKey" android:textColor="#262626" android:textSize="30dp" /> </com.javacodegeeks.androidmultitouchexample.TouchableFrameLayout> </LinearLayout>


Creating the source code of the TouchableFrameLayout FrameLayout

Add a new Java class inside src/com.javacodegeeks.androidmultitouchexample/ so that we are going to have the src/com.javacodegeeks.androidmultitouchexample/ file and paste the code below. package com.javacodegeeks.androidmultitouchexample; import import import import import import

android.content.Context;; android.util.AttributeSet; android.util.SparseArray; android.view.MotionEvent; android.widget.FrameLayout;

public class TouchableFrameLayout extends FrameLayout { private SparseArray mActivePointers = new SparseArray(); private OnTouchListener onTouchListener; float lastXPosition; float lastYPosition; double lastdist = 0; Context ctx; private boolean onScaleMove = false; public TouchableFrameLayout(Context context) { super(context); ctx = context; }

public TouchableFrameLayout(Context context, AttributeSet attrs) { super(context, attrs); ctx = context; } public TouchableFrameLayout(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); ctx = context; }


This is Yahya Christian School Magazine

Read more
Read more
Similar to
Popular now
Just for you