Android button原理
2010-05-31 14:45:00 来源:WEB开发网20. ENABLED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, // 0 1 1 1 1
21. PRESSED_STATE_SET, // 1 0 0 0 0
22. PRESSED_WINDOW_FOCUSED_STATE_SET, // 1 0 0 0 1
23. PRESSED_SELECTED_STATE_SET, // 1 0 0 1 0
24. PRESSED_SELECTED_WINDOW_FOCUSED_STATE_SET, // 1 0 0 1 1
25. PRESSED_FOCUSED_STATE_SET, // 1 0 1 0 0
26. PRESSED_FOCUSED_WINDOW_FOCUSED_STATE_SET, // 1 0 1 0 1
27. PRESSED_FOCUSED_SELECTED_STATE_SET, // 1 0 1 1 0
28. PRESSED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, // 1 0 1 1 1
29. PRESSED_ENABLED_STATE_SET, // 1 1 0 0 0
30. PRESSED_ENABLED_WINDOW_FOCUSED_STATE_SET, // 1 1 0 0 1
31. PRESSED_ENABLED_SELECTED_STATE_SET, // 1 1 0 1 0
32. PRESSED_ENABLED_SELECTED_WINDOW_FOCUSED_STATE_SET, // 1 1 0 1 1
33. PRESSED_ENABLED_FOCUSED_STATE_SET, // 1 1 1 0 0
34. PRESSED_ENABLED_FOCUSED_WINDOW_FOCUSED_STATE_SET, // 1 1 1 0 1
35. PRESSED_ENABLED_FOCUSED_SELECTED_STATE_SET, // 1 1 1 1 0
36. PRESSED_ENABLED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, // 1 1 1 1 1
37. };
设置background的代码:
1. /**
2. * Set the background to a given Drawable, or remove the background. If the
3. * background has padding, this View's padding is set to the background's
4. * padding. However, when a background is removed, this View's padding isn't
5. * touched. If setting the padding is desired, please use
6. * {@link #setPadding(int, int, int, int)}.
7. *
8. * @param d The Drawable to use as the background, or null to remove the
9. * background
10. */
11. public void setBackgroundDrawable(Drawable d) {
12.
13. ...
14.
15. if (d.isStateful()) {
16. d.setState(getDrawableState());
更多精彩
赞助商链接