gpt4 book ai didi

借助 seekbar 进行放大和缩小的 Android 程序?

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:50:04 26 4
gpt4 key购买 nike

我想根据搜索栏的运动放大和缩小图像! !任何人都可以帮助我做到这一点,请您及时回复,我们将不胜感激! ! !

最佳答案

onProgressChanged() 方法做我想做的事! !

公共(public)类 MainActivity 扩展 Activity 实现 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;
}

关于借助 seekbar 进行放大和缩小的 Android 程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17106202/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com