我想放大和缩小一个图像相对于运动的搜索栏!!
有人能帮我做这件事吗?请您及时回复,我们将不胜感激!!!!
最佳答案
onprogresschanged()方法做我想做的魔术!!
公共类mainActivity扩展活动实现onSeekBarchangeListener
{
private SeekBar mSeekBar;
Bitmap bm;
ImageView image;
@Override
protected void onCreate(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);
}
@Override
public void onProgressChanged(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);
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar)
{
mSeekBar.setSecondaryProgress(seekBar.getProgress());
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
}