The most basic virtual keypad

The simplest we can go is to build a simple keypad in the shape of a cross on the left-hand side of the screen and a fire button on its right-hand side. For this layout, we are going to create a new file under the layout folder and call it view_keypad.xml:

<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_gravity="bottom" android:padding="@dimen/keypad_size" android:layout_width="match_parent" android:layout_height="wrap_content"> <Button android:id="@+id/keypad_up" android:layout_alignParentTop="true" android:layout_toRightOf="@+id/keypad_left" android:layout_width="@dimen/keypad_size" android:layout_height="@dimen/keypad_size" /> <Button ...

Get Android: Game Programming now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.