|
1 |
| -# 关于适配的问题 |
| 1 | +# 关于属性适配的问题 |
2 | 2 |
|
3 |
| -> 你好,如果你是刚使用这个库的人不必理会,如果你之前使用了 `TitleBar` 这个库,也就是 5.0 版本以下的,在升级到 `5.0` 版本后需要进行适配,否则 `Android Studio` 会报错`编译不通过`,对于这个问题我表示十分抱歉,低版本的 `xml` 属性命名得并不是很规范,现在在 `5.0` 版本给予了纠正,尽管这次的代价比较大,但是我会义无反顾去做,如果你使用了 `TitleBar` 但是不想进行适配,请不要`升级`依赖版本 |
| 3 | +* 你好,如果你是刚使用这个库的人可以不必理会,如果你之前使用了 `TitleBar` 这个库,也就是 5.0 版本以下的,在升级到 `5.0` 版本后需要进行适配,否则 `Android Studio` 会报错`编译不通过`,对于这个问题我表示十分抱歉,低版本的 `xml` 属性命名得并不是很规范,现在在 `5.0` 版本给予了纠正,尽管这次的代价比较大,但是我会义无反顾去做,如果你使用了 `TitleBar` 但是不想进行适配,请不要`升级`依赖版本。 |
4 | 4 |
|
5 | 5 | #### 3.5 版本属性命名
|
6 | 6 |
|
7 |
| - <declare-styleable name="TitleBar"> |
8 |
| - <!-- 标题栏的样式 --> |
9 |
| - <attr name="bar_style"> |
10 |
| - <enum name="light" value="0x10" /> |
11 |
| - <enum name="night" value="0x20" /> |
12 |
| - <enum name="transparent" value="0x30" /> |
13 |
| - </attr> |
14 |
| - <!-- 标题 --> |
15 |
| - <attr name="title" format="string" /> |
16 |
| - <attr name="title_left" format="string"/> |
17 |
| - <attr name="title_right" format="string" /> |
18 |
| - <!-- 图标 --> |
19 |
| - <attr name="icon_left" format="reference" /> |
20 |
| - <attr name="icon_right" format="reference" /> |
21 |
| - <!-- 返回按钮,默认开 --> |
22 |
| - <attr name="icon_back" format="boolean" /> |
23 |
| - <!-- 文字颜色 --> |
24 |
| - <attr name="color_title" format="color" /> |
25 |
| - <attr name="color_right" format="color" /> |
26 |
| - <attr name="color_left" format="color" /> |
27 |
| - <!-- 文字大小 --> |
28 |
| - <attr name="size_title" format="dimension" /> |
29 |
| - <attr name="size_right" format="dimension" /> |
30 |
| - <attr name="size_left" format="dimension" /> |
31 |
| - <!-- 按钮背景 --> |
32 |
| - <attr name="background_left" format="reference|color" /> |
33 |
| - <attr name="background_right" format="reference|color" /> |
34 |
| - <!-- 分割线 --> |
35 |
| - <attr name="line_visible" format="boolean" /> |
36 |
| - <attr name="line_color" format="color" /> |
37 |
| - <attr name="line_size" format="dimension" /> |
38 |
| - </declare-styleable> |
| 7 | +```xml |
| 8 | +<declare-styleable name="TitleBar"> |
| 9 | + <!-- 标题栏的样式 --> |
| 10 | + <attr name="bar_style"> |
| 11 | + <enum name="light" value="0x10" /> |
| 12 | + <enum name="night" value="0x20" /> |
| 13 | + <enum name="transparent" value="0x30" /> |
| 14 | + </attr> |
| 15 | + <!-- 标题 --> |
| 16 | + <attr name="title" format="string" /> |
| 17 | + <attr name="title_left" format="string"/> |
| 18 | + <attr name="title_right" format="string" /> |
| 19 | + <!-- 图标 --> |
| 20 | + <attr name="icon_left" format="reference" /> |
| 21 | + <attr name="icon_right" format="reference" /> |
| 22 | + <!-- 返回按钮,默认开 --> |
| 23 | + <attr name="icon_back" format="boolean" /> |
| 24 | + <!-- 文字颜色 --> |
| 25 | + <attr name="color_title" format="color" /> |
| 26 | + <attr name="color_right" format="color" /> |
| 27 | + <attr name="color_left" format="color" /> |
| 28 | + <!-- 文字大小 --> |
| 29 | + <attr name="size_title" format="dimension" /> |
| 30 | + <attr name="size_right" format="dimension" /> |
| 31 | + <attr name="size_left" format="dimension" /> |
| 32 | + <!-- 按钮背景 --> |
| 33 | + <attr name="background_left" format="reference|color" /> |
| 34 | + <attr name="background_right" format="reference|color" /> |
| 35 | + <!-- 分割线 --> |
| 36 | + <attr name="line_visible" format="boolean" /> |
| 37 | + <attr name="line_color" format="color" /> |
| 38 | + <attr name="line_size" format="dimension" /> |
| 39 | +</declare-styleable> |
| 40 | +``` |
39 | 41 |
|
40 | 42 | #### 5.0 版本属性命名
|
41 | 43 |
|
42 |
| - <declare-styleable name="TitleBar" tools:ignore="ResourceName"> |
43 |
| - <!-- 整体样式 --> |
44 |
| - <attr name="barStyle"> |
45 |
| - <enum name="light" value="0x10" /> |
46 |
| - <enum name="night" value="0x20" /> |
47 |
| - <enum name="transparent" value="0x30" /> |
48 |
| - </attr> |
49 |
| - <!-- 中间 --> |
50 |
| - <attr name="title" format="string" /> |
51 |
| - <attr name="titleColor" format="color" /> |
52 |
| - <attr name="titleSize" format="dimension" /> |
53 |
| - <!-- 左边 --> |
54 |
| - <attr name="leftTitle" format="string"/> |
55 |
| - <attr name="leftIcon" format="reference" /><!-- leftIcon 优先于 backButton --> |
56 |
| - <attr name="backButton" format="boolean" /><!-- 返回按钮(默认开) --> |
57 |
| - <attr name="leftColor" format="color" /> |
58 |
| - <attr name="leftSize" format="dimension" /> |
59 |
| - <attr name="leftBackground" format="reference|color" /> |
60 |
| - <!-- 右边 --> |
61 |
| - <attr name="rightTitle" format="string" /> |
62 |
| - <attr name="rightIcon" format="reference" /> |
63 |
| - <attr name="rightColor" format="color" /> |
64 |
| - <attr name="rightSize" format="dimension" /> |
65 |
| - <attr name="rightBackground" format="reference|color" /> |
66 |
| - <!-- 分割线 --> |
67 |
| - <attr name="lineVisible" format="boolean" /> |
68 |
| - <attr name="lineColor" format="reference|color" /> |
69 |
| - <attr name="lineSize" format="dimension" /> |
70 |
| - </declare-styleable> |
| 44 | +```xml |
| 45 | +<declare-styleable name="TitleBar" tools:ignore="ResourceName"> |
| 46 | + <!-- 整体样式 --> |
| 47 | + <attr name="barStyle"> |
| 48 | + <enum name="light" value="0x10" /> |
| 49 | + <enum name="night" value="0x20" /> |
| 50 | + <enum name="transparent" value="0x30" /> |
| 51 | + </attr> |
| 52 | + <!-- 中间 --> |
| 53 | + <attr name="title" format="string" /> |
| 54 | + <attr name="titleColor" format="color" /> |
| 55 | + <attr name="titleSize" format="dimension" /> |
| 56 | + <!-- 左边 --> |
| 57 | + <attr name="leftTitle" format="string"/> |
| 58 | + <attr name="leftIcon" format="reference" /><!-- leftIcon 优先于 backButton --> |
| 59 | + <attr name="backButton" format="boolean" /><!-- 返回按钮(默认开) --> |
| 60 | + <attr name="leftColor" format="color" /> |
| 61 | + <attr name="leftSize" format="dimension" /> |
| 62 | + <attr name="leftBackground" format="reference|color" /> |
| 63 | + <!-- 右边 --> |
| 64 | + <attr name="rightTitle" format="string" /> |
| 65 | + <attr name="rightIcon" format="reference" /> |
| 66 | + <attr name="rightColor" format="color" /> |
| 67 | + <attr name="rightSize" format="dimension" /> |
| 68 | + <attr name="rightBackground" format="reference|color" /> |
| 69 | + <!-- 分割线 --> |
| 70 | + <attr name="lineVisible" format="boolean" /> |
| 71 | + <attr name="lineColor" format="reference|color" /> |
| 72 | + <attr name="lineSize" format="dimension" /> |
| 73 | +</declare-styleable> |
| 74 | +``` |
71 | 75 |
|
72 | 76 | #### 适配方案
|
73 | 77 |
|
74 |
| -> 常规适配:单词反向,不再采用下划线形式,而用单词开头大写的方式代替 |
| 78 | +* 常规适配:单词反向,不再采用下划线形式,而用单词开头大写的方式代替 |
75 | 79 |
|
76 |
| -3.5 版本 | 5.0 版本 |
77 |
| ------------- | ------------- |
78 |
| -title_left | leftTitle |
79 |
| -title_right | rightTitle |
80 |
| -icon_left | leftIcon |
81 |
| -icon_right | rightIcon |
82 |
| -color_title | titleColor |
83 |
| -color_right | rightColor |
84 |
| -color_left | leftColor |
85 |
| -size_title | titleSize |
86 |
| -size_right | rightSize |
87 |
| -size_left | leftSize |
88 |
| -background_left | leftBackground |
89 |
| -background_right| rightBackground |
| 80 | +| 3.5 版本 | 5.0 版本 |
| 81 | +| :------------: | :-------------: | |
| 82 | +| title_left | leftTitle | |
| 83 | +| title_right | rightTitle | |
| 84 | +| icon_left | leftIcon | |
| 85 | +| icon_right | rightIcon | |
| 86 | +| color_title | titleColor | |
| 87 | +| color_right | rightColor | |
| 88 | +| color_left | leftColor | |
| 89 | +| size_title | titleSize | |
| 90 | +| size_right | rightSize | |
| 91 | +| size_left | leftSize | |
| 92 | +| background_left | leftBackground | |
| 93 | +| background_right| rightBackground | |
90 | 94 |
|
91 |
| -> 特殊适配:去除下划线,并且用单词开头大写的方式代替 |
| 95 | +* 特殊适配:去除下划线,并且用单词开头大写的方式代替 |
92 | 96 |
|
93 |
| - 3.5 版本 | 5.0 版本 |
94 |
| - ------- | ------------- |
95 |
| -bar_style | barStyle |
96 |
| -line_visible | lineVisible |
97 |
| -line_color | lineColor |
98 |
| -line_size | lineSize |
| 97 | +| 3.5 版本 | 5.0 版本 | |
| 98 | +| :-------: | :---------: | |
| 99 | +| bar_style | barStyle | |
| 100 | +| line_visible | lineVisible | |
| 101 | +| line_color | lineColor | |
| 102 | +| line_size | lineSize | |
99 | 103 |
|
100 |
| -> 极端适配:命名和之前完全不同 |
| 104 | +* 极端适配:命名和之前完全不同 |
101 | 105 |
|
102 |
| - 3.5 版本 | 5.0 版本 |
103 |
| - ------- | ------------- |
104 |
| -icon_back | backButton |
| 106 | +| 3.5 版本 | 5.0 版本 | |
| 107 | +| :-------: | :-------: | |
| 108 | +| icon_back | backButton | |
105 | 109 |
|
106 |
| -> 无需适配:这个属性没有任何改动 |
| 110 | +* 无需适配:这个属性没有任何改动 |
107 | 111 |
|
108 |
| -3.5 版本 | 5.0 版本 |
109 |
| ------- | ------------- |
110 |
| -title | title |
| 112 | +| 3.5 版本 | 5.0 版本 | |
| 113 | +| :-----: | :-------: | |
| 114 | +| title | title | |
111 | 115 |
|
0 commit comments