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 8040535
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T03:55:42+00:00 2026-06-05T03:55:42+00:00

I have login screen ,I want to center the button so I used android:layout_centerHorizontal=true

  • 0

I have login screen ,I want to center the button so I used android:layout_centerHorizontal="true"

the layout xml is

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_centerHorizontal="true"
    android:background="#DDDDDD"
    android:gravity="center_vertical|center_horizontal" >

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:background="@drawable/loginlayoutborders"
        android:orientation="vertical" >

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            gra=""
            android:orientation="horizontal" >

            <TextView
                android:id="@+id/tv_url"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="URL:             "
                android:textColor="#444444"
                android:textSize="10pt" />

            <EditText
                android:id="@+id/et_url"
                android:layout_width="400dip"
                android:layout_height="50dip"
                android:layout_toRightOf="@id/tv_url"
                android:background="@android:drawable/editbox_background" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            gra=""
            android:orientation="horizontal" >

            <TextView
                android:id="@+id/tv_un"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="User Name:"
                android:textColor="#444444"
                android:textSize="10pt" />

            <EditText
                android:id="@+id/et_un"
                android:layout_width="400dip"
                android:layout_height="50dip"
                android:layout_alignTop="@id/tv_un"
                android:layout_toRightOf="@id/tv_un"
                android:background="@android:drawable/editbox_background" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="horizontal" >

            <TextView
                android:id="@+id/tv_pw"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@id/tv_un"
                android:text="Password:"
                android:textColor="#444444"
                android:textSize="10pt" />

            <EditText
                android:id="@+id/et_pw"
                android:layout_width="400dip"
                android:layout_height="50dip"
                android:layout_alignTop="@id/tv_pw"
                android:layout_below="@id/et_un"
                android:layout_marginLeft="17dip"
                android:layout_toRightOf="@id/tv_pw"
                android:background="@android:drawable/editbox_background"
                android:password="true" />
        </LinearLayout>

        <Button
            android:id="@+id/btn_login"
            android:layout_width="100dip"
            android:layout_height="wrap_content"
            android:layout_below="@id/et_pw"
            android:layout_centerHorizontal="true"
            android:text="Login" />

        <TextView
            android:id="@+id/tv_error"
            android:layout_width="fill_parent"
            android:layout_height="40dip"
            android:layout_below="@id/btn_login"
            android:layout_marginLeft="15dip"
            android:layout_marginRight="9dip"
            android:layout_marginTop="15dip"
            android:text=""
            android:textColor="#AA0000"
            android:textSize="7pt" />
    </LinearLayout>

</RelativeLayout>

and the style file is

<?xml version="1.0" encoding="utf-8"?>

<selector xmlns:android="http://schemas.android.com/apk/res/android">

<item>

    <shape>

        <gradient
            android:angle="90"
            android:startColor="#FFFFFF"
            android:endColor="#FFFFFF"
            android:type="linear" />

        <padding android:left="50dp" android:top="50dp" 
            android:right="50dp" android:bottom="50dp" /> 

        <corners android:radius="4dp" /> 

    </shape>

</item>

</selector>

but the button always be at the left of the screen, any idea how to fix that

  • 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-05T03:55:44+00:00Added an answer on June 5, 2026 at 3:55 am

    add android:layout_gravity to center for button

     <Button
                android:layout_gravity="center"
                android:id="@+id/btn_login"
                android:layout_width="100dip"
                android:layout_height="wrap_content"
                android:layout_below="@id/et_pw"
                android:layout_centerHorizontal="true"
                android:text="Login" />
     </LinearLayout>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a login screen and there is some registration button and login button.
I have a login screen with two EditTexts and a login button in my
I have a user login screen. The user presses a login button and I
In my android app I have a login screen. A graphic designer has given
I have the following situation: I begin with a login screen (which I want
My app has a main screen where i have button to go to login
I'm creating a login screen(username,password as two fields, Login button).Now, I have to enter
I have a fixed size layout where I center the content container. I want
I have a login screen that is branded differently for different builds of my
I have a login screen for a UITabBar application where users are divided into

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.