title: How to zoom and scroll a textview?
body: <p>I am unable to implement scrolling and zooming of a textview.
  I looked at similar questions but was unable to get any satisfactory solution.
  I know a webview would be easier to implement but it was unable to perform font color change for certain keywords in it.</p>
  
  <p>My code is as follows.I have implemented scrolling only :</p>
  
  <pre><code>package com.example.myclass;
  
  
  import android.app.Activity;
  import android.content.Intent;
  import android.database.Cursor;
  import android.database.sqlite.SQLiteDatabase;
  import android.os.Bundle;
  import android.text.Spannable;
  import android.text.SpannableString;
  import android.text.Spanned;
  import android.text.TextUtils;
  import android.text.method.ScrollingMovementMethod;
  import android.text.style.ForegroundColorSpan;
  import android.util.Log;
  import android.util.TypedValue;
  import android.view.Menu;
  import android.view.MenuInflater;
  import android.view.MotionEvent;
  import android.widget.TextView;
  
  
  public class viewProgramActivity&lt;x&gt; extends Activity{
  
      private SQLiteDatabase database;
      ExternalDbOpenHelper dbOpenHelper;
      private static TextView textView;
      private static final String DB_NAME = "umangdb.db";
      private String rowid;
      private String programtext;
      ScaleGestureDetector scaleGestureDetector;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) 
      {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.viewprogram);
  
          registerForContextMenu(findViewById(R.id.textView1));
  
          dbOpenHelper = new ExternalDbOpenHelper(this, DB_NAME);
          database = dbOpenHelper.openDataBase();
  
          Intent intent=getIntent();
          rowid=intent.getStringExtra("myextra");
  
          String query="select * from engg_table where _id="+rowid;
          Cursor myCursor = database.rawQuery(query,null);
          myCursor.moveToFirst();
  
          programtext=myCursor.getString(4);
          myCursor.close();
  
          textView  = (TextView) findViewById(R.id.textView1);
          textView.setText(programtext);
  
  
  
  
          textView.setMovementMethod(new ScrollingMovementMethod());
  
  
          String [] keywordsred={"int","char","{","}"};
          for(String y:keywordsred)
          {
          fontcolor(y,0xffff0000);
          }
  
          String [] keywordspurple={"printf","scanf","#include&lt;stdio.h&gt;","%d","%f","%s","%c"};
          for(String y:keywordspurple)
          {
          fontcolor(y,0xFF8B008B);
          }
  
      }
  
      private void fontcolor(String text,int color) {
          textView=(TextView)findViewById(R.id.textView1);
          Spannable raw=new SpannableString(textView.getText());
  
          int index=TextUtils.indexOf(raw, text);
          while (index &gt;= 0) {
            raw.setSpan(new ForegroundColorSpan(color), index, index
                + text.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
            index=TextUtils.indexOf(raw, text, index + text.length());
          }
          textView.setText(raw);
  
        }
  
  
  
     @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          MenuInflater inflater = getMenuInflater();
          inflater.inflate(R.menu.optionsmenu, menu);
  
          return true;
      }
  
  }   
  </code></pre>
  
  <p>Corresponding XML:</p>
  
  <pre><code>&lt;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"
      tools:context=".MainActivity" &gt;
  
      &lt;TextView
          android:id="@+id/textView1"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignParentBottom="true"
          android:layout_alignParentLeft="true"
          android:layout_alignParentRight="true"
          android:layout_alignParentTop="true"
          android:text="@string/uecp" /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>What code should be added to this to enable zooming,I tried many methods but failed to implement.I'm a beginner to java and android.Please explain in detail</p>