setting android button invisible but still having an onClick Listener attached

后端 未结 10 1561
情深已故
情深已故 2021-02-06 06:39

So currently I\'m putting an Easter egg inside my app and I want the Button to be invisible, but when clicked(Rick roll). So far I can make it work when I say:

10条回答
  •  隐瞒了意图╮
    2021-02-06 07:06

    In your layout, make your button have a specific width, like android:layout_width="40dp".

    If your width is set to wrap_content with a transparent background and no text, Android will measure that view as having a width of 0dp. You'll never be able to click on that.

提交回复
热议问题