Android Program For Zoom In And Out With Help Of Seekbar?
I want to zoom in and zoom out an image with respect to motion of the seek bar! ! can anyone help me to do this please your prompt response 'll be highly appreciated ! ! !
Solution 1:
onProgressChanged() method do the magic which i want to ! !
public class MainActivity extends Activity implements OnSeekBarChangeListener {
privateSeekBar mSeekBar;
Bitmap bm;
ImageView image;
@OverrideprotectedvoidonCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mSeekBar = (SeekBar) findViewById(R.id.seekBar);
mSeekBar.setOnSeekBarChangeListener((OnSeekBarChangeListener) this);
image=(ImageView)findViewById(R.id.image);
bm=BitmapFactory.decodeResource(getResources(), R.drawable.sachin);
}
@OverridepublicvoidonProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
Bitmap resizedbitmap=Bitmap.createScaledBitmap(bm,10, 10, true);
if(progress>0&&progress<=25)
{
resizedbitmap=Bitmap.createScaledBitmap(bm,70, 70, true);
}
if(progress>26&&progress<=50)
{
resizedbitmap=Bitmap.createScaledBitmap(bm,120, 120, true);
}
if(progress>51&&progress<=75)
{
resizedbitmap=Bitmap.createScaledBitmap(bm,180, 180, true);
}
if(progress>76&&progress<=100)
{
resizedbitmap=Bitmap.createScaledBitmap(bm,220, 220, true);
}
image.setImageBitmap(resizedbitmap);
}
@OverridepublicvoidonStartTrackingTouch(SeekBar seekBar) {
}
@OverridepublicvoidonStopTrackingTouch(SeekBar seekBar)
{
mSeekBar.setSecondaryProgress(seekBar.getProgress());
}
@OverridepublicbooleanonCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
returntrue;
}
}
Solution 2:
I don't quite understand if this is what you want but here's some links that can help you with that.
This is to understand how seekbars
work. You need to set a listener.
http://rajeshvijayakumar.blogspot.pt/2013/01/seek-bar-example-in-android.html
After that, you need to get the values of the seekbar
and use this exame to scale the bitmap using BitmapFactory
.
http://developer.android.com/training/displaying-bitmaps/load-bitmap.html
Hope it helps.
Post a Comment for "Android Program For Zoom In And Out With Help Of Seekbar?"