Considering the main purpose of a button is to react to a click event, and the fact that both Button
and TextView
has properties for text, drawable (icon) and click event, what is the actual difference between them, when should you chose one over the other?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Looking at the reference docs, the Button class extends the TextView class. From there, the Button adds a few stylistic changes (e.g., default background image, additional padding) to allow quicker adaptation to your designs.
IMO, the one you choose to use should depend on how you want to design your app. If you use the default theme with minimal stylistic changes, Buttons can be quicker to visualize; on the other hand, if you are doing a lot of customization, TextView will let you do that much easier.
**Edit: ** GrepCode shows that from a functionality point of view, there is no difference aside from class name.