O'Reilly logo

Mastering Android Game Development by Raul Portales

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required