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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:59:09+00:00 2026-05-22T18:59:09+00:00

I am using EditText and providing some Hint there. I am putting it like

  • 0

I am using EditText and providing some Hint there. I am putting it like this:

android:hint="@string/user_name_hint"
android:textColorHint="#ffffff"
android:gravity="left"

But here hint is coming in the left side. But i want the hint is in the middle of the box and when i am clicking the text should start from the left.

How it is 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-05-22T18:59:10+00:00Added an answer on May 22, 2026 at 6:59 pm

    Use this EditText

     <EditText
        android:layout_height="wrap_content"
        android:layout_width="fill_parent"
        android:hint="user_name_hint"
        android:textColorHint="#fffff"
        android:gravity="center_horizontal"
        android:id="@+id/editText1"/>
    

    Then you need to add addTextChangedListener to solve your problem.

     final EditText hintText = (EditText) findViewById(R.id.editText1);
                hintText.addTextChangedListener(new TextWatcher() {
    
                    @Override
                    public void onTextChanged(CharSequence s, int start, int before,
                            int count) {
                    }
    
                    @Override
                    public void beforeTextChanged(CharSequence s, int start, int count,
                            int after) {
    
                    }
    
                    @Override
                    public void afterTextChanged(Editable s) {
                        if (s.length() == 0) {
                            hintText.setGravity(Gravity.CENTER);
                        } else {
                            hintText.setGravity(Gravity.LEFT);
    
                        }
    
                    }
                });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an EditText using android:inputType=textPostalAddress as the keyboard type. I would like it
This is the code I am using in android programming EditText pass1,pass2; Button register=(Button)
i am using android:imeOptions=actionSearch in editText and my question is can i write my
Hi I am developing an Android app using an EditText, and a add en
I am using HTML.fromHTML(...) to style the text of an EditText in Android. I
I made a simple beanshell ide in android using an edittext and a button.
I am using a simple EditText and register an View.OnKeyListener . Some GUI changes
Ok, I'm using the code: EditText editText = (EditText) findViewById(R.id.editText1); String value = editText.getText().toString();
When I'm using edittext.setError(enter a comment) in android, it works fine until the keyboard
In an Android app, I'm using two EditText controls and multiplying their two values.

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.