java如何在安卓应用程序中使用按钮增加/减少图像视图的宽度和高度? 1 周,3 日 Questions & Answers 228 我的安卓应用程序中有两个按钮。 “(+)增加图像尺寸”&;“”(-)双区域图像维度“” 我想点击以增加或减少我拥有的图像视图 就这些
# 1 楼答案 尝试这样的方法将width和height增加5: final android.view.ViewGroup.LayoutParams layoutParams = imageView.getLayoutParams(); buttonIncrease.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { layoutParams.width += 5; layoutParams.height += 5; imageView.setLayoutParams(layoutParams); } });
# 1 楼答案
尝试这样的方法将
width
和height
增加5:# 2 楼答案
imageView。getLayoutParams()。高度+=1;(或-) imageView。getLayoutParams()。宽度+=1