简书链接:keyboard的间隙详解
文章字数:709,阅读全文大约需要2分钟

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73


<Row android:verticalGap="1.9%p">
<Key android:codes="20140" android:keyLabel="10%"
android:horizontalGap="10%p"
android:keyWidth="40%p"
android:keyEdgeFlags="left" />
<Key android:codes="27941" android:keyLabel="10%"
android:horizontalGap="10%p" android:keyWidth="40%p" />
</Row>


<Row android:verticalGap="1.9%p">
<Key android:codes="20140" android:keyLabel="5%"
android:horizontalGap="5%p" android:keyWidth="40%p"
android:keyEdgeFlags="left" />
<Key android:codes="27941" android:keyLabel="10%"
android:horizontalGap="10%p" android:keyWidth="40%p" />
</Row>

<Row android:verticalGap="1.9%p">
<Key android:codes="20140" android:keyLabel="5%"
android:horizontalGap="5%p" android:keyWidth="40%p"
android:keyEdgeFlags="left" />
<Key android:codes="27941" android:keyLabel="5%"
android:horizontalGap="5%p" android:keyWidth="40%p" />
</Row>





<Row android:verticalGap="1.9%p">
<Key android:codes="20140" android:keyLabel="5%"
android:horizontalGap="6.5%p" android:keyWidth="40%p"
android:keyEdgeFlags="left" />

<Key android:codes="27941" android:keyLabel=""
android:horizontalGap="0.2%p" android:keyWidth="0dp" />
<Key android:codes="27941" android:keyLabel="5..%"
android:horizontalGap="6.5%p" android:keyWidth="40%p" />
</Row>




<Row android:verticalGap="1.9%p">
<Key android:codes="20140" android:keyLabel="7.5%"
android:horizontalGap="7.5%p" android:keyWidth="40%p"
/>
<Key android:codes="27941" android:keyLabel="7.5%"
android:horizontalGap="7.5%p" android:keyWidth="40%p" />
</Row>

<Row android:verticalGap="1.9%p">
<Key android:codes="20140" android:keyLabel="7.3%"
android:horizontalGap="7.3%p" android:keyWidth="40%p"
/>
<Key android:codes="27941" android:keyLabel="7.5%"
android:horizontalGap="7.5%p" android:keyWidth="40%p" />
</Row>




<Row android:verticalGap="1.9%p">
<Key android:codes="20140" android:keyLabel="0%"
android:keyWidth="100%p"
android:keyEdgeFlags="left" />
</Row>



image.png

间隙也就是两边的间隙,比如这里2个按钮一个占用了百分之80 那么屏幕的百分之20如何规划呢?
实际上应该让各自的边界都只有7.5% 然后中间 7.5x2=15 剩下的百分之5就是中间的,但是为什么图上面出现这种情况呢?我发现给按钮百分之百也是这样,所以问题不是出在这里了。
看来是前人代码本来写错了,那么再看看
![EXT4GP$3~N8]T@%{TQS042.png

上面的解决方法就是中间插入一个按钮方可实现均衡间隙,否则无法实现

按键适配
设计图宽度2048 ,按键宽度140,
w, 2048 width 140 132 14010=1400 占用百分比 占用 百分之68.3 =6.83% 也可以用 140/2048100=6.83
直接6.8 剩下百分之32/10 那么导致的结果是多了。
间隙10 那么就是5 ,32/5=6.4但是左右怎么办?