【问题标题】:How to transfer image from button1 to button2?如何将图像从按钮1传输到按钮2?
【发布时间】:2022-01-27 08:50:05
【问题描述】:

是否可以在 Android Studio 中将按钮的背景图像提供给另一个按钮,就像我们在变量之间传递值一样? 我想要类似的东西: btn_1.setBackgroundResource = btn_2.setBackgroundResource

【问题讨论】:

  • 是的。获取drawable并设置drawable。
  • 你能告诉我语法是怎样的吗?
  • 这是 ImageButton 还是 Button?
  • 是ImageButton

标签: android image android-studio button


【解决方案1】:
button1.setBackground(button2.getBackground());

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-01-26
    • 1970-01-01
    • 1970-01-01
    • 2012-06-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多