2
votes

I have a row of keys. Each key is 18.5% width with 2% gap. I however want the gap on the first key to be 10% and the gap on the last key to be 10% on the right side. It's simple to set the horizontalGap on each key to achieve this effect, except I see no way to set the right side gap.

The spacing I want is as follows (bracketed items are keys, else it's a gap):

10% [18.5%] 2% [18.5%] 2% [18.5%] 2% [18.5%] 10%

I have tried:

<Keyboard xmlns:android="http://schemas.android.com/apk/res/android"
    android:keyWidth="18.5%p"
    android:horizontalGap="2%"
    android:keyHeight="7%p">

    <Row>
        <Key android:codes="1" android:keyLabel="1" android:horizontalGap="10%p" />
        <Key android:codes="2" android:keyLabel="2" />
        <Key android:codes="3" android:keyLabel="3" />
        <Key android:codes="4" android:keyLabel="4"  />
    </Row>
</Keyboard>

This does not give me a 10% gap despite by KeyboardView width set to fill_parent. How can my keyboard have a 10% gap after the keys in a row?

1

1 Answers

1
votes

Set the width to wrap_content and center it horizontally within its parent.