【问题标题】:how to increase/decrease imageView width and height with buttons in android app?如何使用 android 应用程序中的按钮增加/减少 imageView 的宽度和高度?
【发布时间】:2016-03-24 21:41:00
【问题描述】:

我的安卓应用中有两个按钮。 "(+)增加图像尺寸" & "" (-)增加图像尺寸"" 我想通过点击来增加或减少我拥有的 imageView。

就是这样!

【问题讨论】:

标签: java android xml android-layout android-studio


【解决方案1】:

尝试这样的操作将 widthheight 增加 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);
        }
    });

【讨论】:

    【解决方案2】:

    imageView.getLayoutParams().height += 1; (或者 -) imageView.getLayoutParams().width += 1;

    【讨论】:

    • 请编辑格式。复制和粘贴不是答案:)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-04-22
    • 2015-11-24
    • 1970-01-01
    • 1970-01-01
    • 2011-05-15
    • 1970-01-01
    • 2023-03-18
    相关资源
    最近更新 更多