Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9129747
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T07:49:08+00:00 2026-06-17T07:49:08+00:00

I want to design a login screen. The content should be horizontally and vertically

  • 0

I want to design a login screen. The content should be horizontally and vertically alinged center. So far I have created this:

enter image description here

Currently I have given marginTop to my top element i.e. the icon. But I don’t think it’s a proper way. I want the username field to be in the vertical center of the screen. This will move the whole content in the middle of the screen.

Here is my layout code so far:

<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"
    tools:context=".LoginActivity" 
    android:background="#d1d6df">

    <ImageView 
        android:id="@+id/imgIcon"
        android:src="@drawable/ic_launcher"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:contentDescription="Icon"
        android:layout_marginBottom="20dp"
        android:layout_marginTop="120dp"
        android:layout_centerHorizontal="true"/>

    <EditText
        android:id="@+id/txtUsername"
        android:hint="Username"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_below="@+id/imgIcon"
        android:ems="10"
        android:inputType="text">

        <requestFocus />
    </EditText>

    <EditText
        android:id="@+id/txtPassword"
        android:hint="@string/passwordHint"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_below="@+id/txtUsername"
        android:ems="10"
        android:inputType="textPassword">
    </EditText>

    <Button
        android:text="@string/loginButtonText"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_below="@+id/txtPassword"
        />

</RelativeLayout>

Also I want Login button to get width from its upper sibling, i.e. Password field. Is that possible?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T07:49:10+00:00Added an answer on June 17, 2026 at 7:49 am
    1. Remove the marginTop and add android:gravity="center" on your relativeLayout
    2. Add android:layout_alignLeft="@+id/txtPassword" and android:layout_alignRight="@+id/txtPassword" to your button

    Hope this will help you 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to design a layout for my login screen, I tried the following
I want to design a login and register layout using android tabs. Image is
I want to design a webpage login that when click on the login button
I want design my startup screen with progress bar. But I don't how to
I want to design a new category this category will be separated from the
I am writing an app and I want to show the login screen just
I'm building Rails application and I want to have user registration/login functionality. I also
I have the follow problem. This is the situation i've got when user login
I am new to the iPhone development.I want to design a login form for
How should I design a login system so that each username can only be

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.