<?xml version="1.0" encoding="utf-8"?> <!-- Copyright 2014 Google Inc. All Rights Reserved. --> <!-- This mess is all to draw a rectangle in the right place on the screen. Here's what's going on: - Keyboard uses the intrinsic size of the drawable to work out where the drawable should be centered in the key. - Inset uses the intrinsic size of its inner drawable. This effectively scales the drawable down to add padding, and doesn't make the drawable bigger. - LayerList uses the maximum intrinsic size of its items as its intrinsic size. - So, we use a LayerList with a blank shape that assumes the size of the keyboard key. - We then add an inset with insetTop + insetBottom + inner shape = size of key. --> <layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <item> <shape> <size android:height="@dimen/keyboard_key_height" android:width="@dimen/keyboard_key_spacebar_width" /> <solid android:color="@color/ime_background_letters" /> </shape> </item> <item> <inset android:insetTop="@dimen/keyboard_spacebar_pressed_margin" android:insetBottom="@dimen/keyboard_spacebar_pressed_margin" android:insetLeft="@dimen/keyboard_key_spacebar_visual_horizontal_padding" android:insetRight="@dimen/keyboard_key_spacebar_visual_horizontal_padding" > <shape android:shape="rectangle"> <size android:height="@dimen/keyboard_spacebar_height" android:width="@dimen/keyboard_key_spacebar_visual_width" /> <corners android:radius="@dimen/keyboard_spacebar_rounding" /> <solid android:color="@color/ime_foreground_spacebar_pressed" /> </shape> </inset> </item> </layer-list>