Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spacing in custom keyboard

When making a custom keyboard I can get a leading space (space to the left) of a key by using android:horizontalGap="6.25%p.
How do I get trailing space (space to the right)?

like image 861
Acura66 Avatar asked Sep 10 '13 16:09

Acura66


2 Answers

android:horizontalGap="6.25%p.

It creates the gap, which is before the key that carries the horizontalGap attribute. ie. leading space (space to the left) of a key.

eg.

<Row>        
    <Key android:codes="69"    android:keyLabel="E" android:horizontalGap="6.25%p" />
    <Key android:codes="70"    android:keyLabel="F" />        
</Row>

Now add a horizontalGap (on Keyboard level) that is greater than 0, the horizontalGap (on Key level) no longer creates a gap before but now after the key that carries the horizontalGap attribute. ie. trailing space (space to the right) of a key

like image 70
Ritesh Gune Avatar answered Nov 15 '22 23:11

Ritesh Gune


For me on Android 5.1 android:horizontalGap attribute works in following way:

  • If you have in the row sum of all android:keyWidth more than 100 then gap is displayed after key for which it was specified.
  • If the sum is less then 100 then then the gap is before the key

For example. In this case it is before

<Row>
    <Key android:codes="97" android:keyLabel="a" android:horizontalGap="5%p" android:keyEdgeFlags="left"/>
    <Key android:codes="115" android:keyLabel="s"/>
    <Key android:codes="100" android:keyLabel="d"/>
    <Key android:codes="102" android:keyLabel="f"/>
    <Key android:codes="103" android:keyLabel="g"/>
    <Key android:codes="104" android:keyLabel="h"/>
    <Key android:codes="106" android:keyLabel="j"/>
    <Key android:codes="107" android:keyLabel="k"/>
    <Key android:codes="108" android:keyLabel="l"/>
    <Key android:codes="66" android:keyIcon="@drawable/enter_key" android:keyWidth="20%p" android:isRepeatable="true" android:keyEdgeFlags="right"/>
</Row>

And when I change only one value the gap appears after:

<Row>
    <Key android:codes="97" android:keyLabel="a" android:horizontalGap="5%p" android:keyEdgeFlags="left"/>
    <Key android:codes="115" android:keyLabel="s"/>
    <Key android:codes="100" android:keyLabel="d"/>
    <Key android:codes="102" android:keyLabel="f"/>
    <Key android:codes="103" android:keyLabel="g"/>
    <Key android:codes="104" android:keyLabel="h"/>
    <Key android:codes="106" android:keyLabel="j"/>
    <Key android:codes="107" android:keyLabel="k"/>
    <Key android:codes="108" android:keyLabel="l"/>
    <Key android:codes="66" android:keyIcon="@drawable/enter_key" android:keyWidth="22%p" android:isRepeatable="true" android:keyEdgeFlags="right"/>
</Row>
like image 28
Roman Nazarevych Avatar answered Nov 15 '22 23:11

Roman Nazarevych