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: A Developer’s Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.