当我点击“确定”按钮时,我想调整图像大小(overlayButton)。但是,我不知道在我的setSize()方法中放什么。我尝试了“overlayButton.setScaleX(size)”和“overlayButton.setScaleY(size)”但是什么也没做。这是我的代码。实际上,我的图像会调整大小,但只有一次我拖动它。
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
seekTxt.setText(Integer.toString(progress) + "%");
overlayButton.getLayoutParams().width = progress;
overlayButton.getLayoutParams().height = progress;
overlayButton.requestLayout();
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
});
seekDialog.show();
}
}
public void sizeOK(View view) {
if (overlayButton != null) {
setSize(size);
seekDialog.dismiss();
} else {
seekDialog.dismiss();
}
}
public int getSize() {
return Math.round((float) size / 300 * 300);
}
public void setSize(int newSize) {
size = Math.round((float) newSize / 300 * 300);
overlayButton.
}
我很感激有关指向setSize()方法的内容的指针。谢谢!
使用解决方案进行编辑: 需要更新drawable。因此,解决方案是:
public void sizeOK(View view) {
if (overlayButton != null) {
setSize(size);
WindowManager.LayoutParams params = (WindowManager.LayoutParams) overlayButton.getLayoutParams();
wm.updateViewLayout(overlayButton, params);
seekDialog.dismiss();
} else {
seekDialog.dismiss();
}
}