Android Open Source - TouchImageView Switch Scale Type Example Activity






From Project

Back to project page TouchImageView.

License

The source code is released under:

opyright (c) 2012 Michael Ortiz Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Softw...

If you think the Android project TouchImageView listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.ortiz.touch;
/*  w w  w.  j a  va2 s  .  c  o m*/
import com.example.touch.R;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Toast;
import android.widget.ImageView.ScaleType;

public class SwitchScaleTypeExampleActivity extends Activity {
  
  private TouchImageView image;
  private Activity activity;
  private static final ScaleType[] scaleTypes = { ScaleType.CENTER, ScaleType.CENTER_CROP, ScaleType.CENTER_INSIDE, ScaleType.FIT_XY, ScaleType.FIT_CENTER };
  private int index = 0;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_switch_scaletype_example);
    activity = this;
    image = (TouchImageView) findViewById(R.id.img);
    
    //
    // Set next scaleType with each button click
    //
    image.setOnClickListener(new OnClickListener() {
      
      @Override
      public void onClick(View v) {
        index = ++index % scaleTypes.length;
        ScaleType currScaleType = scaleTypes[index];
        image.setScaleType(currScaleType);
        Toast.makeText(activity, "ScaleType: " + currScaleType, Toast.LENGTH_SHORT).show();
      }
    });
  }

}




Java Source Code List

com.ortiz.touch.ExtendedViewPager.java
com.ortiz.touch.MainActivity.java
com.ortiz.touch.MirroringExampleActivity.java
com.ortiz.touch.SingleTouchImageViewActivity.java
com.ortiz.touch.SwitchImageExampleActivity.java
com.ortiz.touch.SwitchScaleTypeExampleActivity.java
com.ortiz.touch.TouchImageView.java
com.ortiz.touch.ViewPagerExampleActivity.java