Skip to content

Cloning a Login Screen Layout Guide

Nathan Esquenazi edited this page Oct 8, 2013 · 32 revisions

Overview

This guide is going to walk us through the step-by-step process of recreating this screenshot in an Android app:

Cutting Assets

First, I will make the downloadable assets available. Keep in mind these were stolen right out of the screenshot and therefore their quality is pretty poor. But it demonstrates the concepts nonetheless. To create the mockup, we need the following assets:

Download those and drag the button images into the drawable-xhdpi folder. Note that in production applications you would multiple sizes of these images for different image densities. We are going to ignore that and provide only extra-high density for this demo (they will be resampled for other densities).

Create Project

Generate a new Android project that uses the highlight icon as the launcher icon:

Generate the project with no additional changes.

Start Basic Layout

There are seven views that will be placed within the layout:

  • TextView (To use highlight...)
  • ImageButton (Facebook)
  • ImageButton (LinkedIn)
  • TextView (Why not email?)
  • TextView (Highlight is based...)
  • TextView (Please let us know...)
  • TextView (We won't post things without...)

Layout Background

Let's start by setting the layout background to white:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#ffffff"
    ...>
</RelativeLayout>

Now the entire background for the screen appears white like the mockup.

ImageButtons

Let's start with the ImageButtons. Drag the two image buttons to the screen and select facebook and linkedin as sources respectively. Now go into the XML and tweak the background property of each to "@null" to remove the button borders.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    ...>

    <ImageButton
        android:id="@+id/btnFacebook"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:background="@null"
        android:contentDescription="@string/facebook_desc"
        android:src="@drawable/facebook_connect" />

    <ImageButton
        android:id="@+id/btnLinkedIn"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/btnFacebook"
        android:layout_below="@+id/btnFacebook"
        android:layout_marginTop="5dp"
        android:background="@null"
        android:contentDescription="@string/linkedin_desc"
        android:src="@drawable/linkedin_connect" />

</RelativeLayout>

Here we've aligned the first button to the top of the parent, used layout_centerHorizontal, set android:background to null to avoid the button border, set text descriptions for android:contentDescription and assigned the android:src to the respective buttons. Now our screen looks like:

References

Finding these guides helpful?

We need help from the broader community to improve these guides, add new topics and keep the topics up-to-date. See our contribution guidelines here and our topic issues list for great ways to help out.

Check these same guides through our standalone viewer for a better browsing experience and an improved search. Follow us on twitter @codepath for access to more useful Android development resources.

Clone this wiki locally