多个 ImageButtons,每个使用 2 个独特的(来自彼此的)图像作为背景,我如何在 XML 中写 "selector"?
Multiple ImageButtons, each using 2 unique (from each other's) image for background, how do I write "selector" in XML?
- 我有 24 个按钮
- 他们都有2个州
- 所有 24 个按钮(a.k.a 48 个图像)的每个状态都不同
如何在 xml 中的一个选择器中写入所有状态?或者我需要 24 xmls?
所以,这个问题最好通过创建自己的 Button 子类并使用它来声明项来解决。
黛安·哈克伯恩 (Diane Hackborn) 的老歌 post:https://groups.google.com/forum/#!topic/android-developers/0xzI2bzY-20
她的回答在这里重复:
You could easily make your own custom subclass of button, though, that
had three attributes for the three different drawables and created a
state list drawable itself from them. Then you could have everything
in your single layout file.
- 我有 24 个按钮
- 他们都有2个州
- 所有 24 个按钮(a.k.a 48 个图像)的每个状态都不同
如何在 xml 中的一个选择器中写入所有状态?或者我需要 24 xmls?
所以,这个问题最好通过创建自己的 Button 子类并使用它来声明项来解决。
黛安·哈克伯恩 (Diane Hackborn) 的老歌 post:https://groups.google.com/forum/#!topic/android-developers/0xzI2bzY-20
她的回答在这里重复:
You could easily make your own custom subclass of button, though, that had three attributes for the three different drawables and created a state list drawable itself from them. Then you could have everything in your single layout file.