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

The Archive Base Latest Questions

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

I have an edittext that acts weird when I set a hint to it.

  • 0

I have an edittext that acts weird when I set a hint to it.

XML :

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_marginBottom="5dip"
    android:layout_marginLeft="5dip"
    android:layout_marginTop="8dip"
    android:background="@android:drawable/edit_text"
    android:baselineAligned="false"
    android:gravity="center_vertical"
    android:orientation="horizontal"
    android:paddingRight="0dip" >

    <EditText
        android:id="@+id/pinDisplay"
        android:layout_width="0dip"
        android:layout_height="fill_parent"
        android:layout_weight="0.85"
        android:background="@null"
       />

    <ImageButton
        android:id="@+id/backspace"
        style="@android:style/Widget.Button"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:layout_gravity="center_vertical"
        android:layout_marginBottom="2dip"
        android:layout_marginRight="8dip"
        android:layout_marginTop="2dip"
        android:layout_weight="0.15"
        android:gravity="center"
        android:src="@android:drawable/ic_input_delete" />
</LinearLayout>

Code :

private float hintTextSize = 24;

private void initializeInputText() {
    input = (EditText) findViewById(R.id.pinDisplay);
    input.setInputType(InputType.TYPE_NULL);
    input.setTransformationMethod(PasswordTransformationMethod.getInstance());
    input.setTextSize(TypedValue.COMPLEX_UNIT_SP, hintTextSize);
    input.setHint("Kies pincode");
    input.setCursorVisible(false);

    input.setOnTouchListener(new OnTouchListener() {
        public boolean onTouch(View arg0, MotionEvent arg1) {
            return true;
        }
    });

    input.setFilters(new InputFilter[] { new InputFilter.LengthFilter(maxLengthInput) });
    input.addTextChangedListener(new TextWatcher() {

        public void onTextChanged(CharSequence s, int start, int before,
                int count) {
            input.setError(null);

            if (s.length() >= maxLengthInput) {
                input.setCursorVisible(false);
                btnOk.setEnabled(true);
                btnOk.setTextColor(Color.parseColor("#00B32D")); //Green
            } else {
                btnOk.setEnabled(false);
                btnOk.setTextColor(Color.parseColor("#B8B8B8")); //Light gray
                input.setCursorVisible(true);
                input.setSelection(input.getText().length());
            }
        }

        public void beforeTextChanged(CharSequence s, int start, int count,
                int after) {
        }

        public void afterTextChanged(Editable s) {
            if (!input.getText().toString().equals("")) {
                input.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize);
            } else {
                input.setTextSize(TypedValue.COMPLEX_UNIT_SP, hintTextSize);
            }
        }
    });
}

This is the first:

enter image description here

But when I add a number the edittext grows and takes a lot more space.

enter image description here

What can be the cause ?

  • 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-12T07:17:36+00:00Added an answer on June 12, 2026 at 7:17 am

    Just remove the following code in your class:

             input.setTextSize(TypedValue.COMPLEX_UNIT_SP, hintTextSize);
    

    and try

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

Sidebar

Related Questions

My XMl Layout is as like below: <RelativeLayout android:id=@+id/dateSelectionLayout android:layout_width=fill_parent android:layout_height=wrap_content android:orientation=vertical android:visibility=visible> <EditText
I have a custom EditText MomentumEditText that I have in a layout in xml
I have a EditText that I have set to invisible by default. I would
In my program I have an EditText that I set an OnKeyListener for. The
I have an EditText in Android. Want to rotate that 90 degrees.I konw it
I have an EditText that I am trying to set with a very long,
I have an EditText input that I would like to only allow numbers 1
I have an EditText and I want to attach to it a KeyListener that
I have an edittext, and a textwatcher that watches if SPACE arrived or not.
To use as an example: lets say that I have 2 EditText s and

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.