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

  • Home
  • SEARCH
  • 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 8101643
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T23:01:40+00:00 2026-06-05T23:01:40+00:00

My question is, how to put a label in a editBox in android ?

  • 0

My question is, how to put a label in a editBox in android ?

Like for example, i want to put “To:” in editbox of a contact picker which will not get deleted even if I press backspace on the onscreen keyboard.

I tried with android:hint, but it gets deleted when the editBox is focus or clicked.

I tried with image but it’s not looking good.
So, I need a method by which i can implement this label thing.

See the visual diagram required design

  • 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-05T23:01:41+00:00Added an answer on June 5, 2026 at 11:01 pm

    I give you two ideas to do this :

    If you only need this in a couple of places, you can use a FrameLayout / merge to have a TextView over your EditText. Then using a padding on the edit text, you can make it seem like the TextView is “inside” the EditText. :

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >
    
        <EditText
            android:id="@+id/editText1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:paddingLeft="40dp" >
    
            <requestFocus />
        </EditText>
    
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical"
            android:paddingLeft="10dp"
            android:text="To : " />
    </FrameLayout>
    

    Else you can inplement your own version of EditText, by writing your own Class. Here’s a basic example, you’d need to tweak it a little :

    import android.content.Context;
    import android.graphics.Canvas;
    import android.graphics.Paint;
    import android.graphics.Rect;
    import android.text.TextPaint;
    import android.util.AttributeSet;
    import android.widget.EditText;
    
    public class LabelledEditText extends EditText {
    
        public LabelledEditText(Context context) {
            super(context);
            mPaddingLeft = getPaddingLeft();
        }
    
        public LabelledEditText(Context context, AttributeSet attrs) {
            super(context, attrs);
            mPaddingLeft = getPaddingLeft();
        }
    
        protected void onDraw(Canvas canvas) {
            TextPaint textPaint = getPaint();
            Rect size = new Rect();
            textPaint.getTextBounds(mLabel, 0, mLabel.length(), size);
            setPadding(mPaddingLeft + size.width(), getPaddingTop(), getPaddingRight(), getPaddingBottom());
            super.onDraw(canvas);
    
            canvas.drawText(mLabel, mPaddingLeft + size.left, size.bottom + getPaddingTop(), textPaint);
        }
    
    
        protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
            super.onMeasure(widthMeasureSpec, heightMeasureSpec);
        }
    
        private String mLabel = "To :  ";
        private int mPaddingLeft;
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I don't know exactly how to put this question. I want to create a
This is sort of a follow-up to my question here: Asp:Label is not shown
This might be the silliest question ever. But how do I get to put
Similar to this question I would like to use dropdown plugin called dropkick, which
I have two question to put forward: I was very interested, even intrigued by
Few days back I put a question regarding mapping two classes Message and MessageStatusHistory
How can I put a question mark above a less-than-or-equal-to symbol( \leq ) in
Just a quick question: Say I put an insert trigger on a table in
I think this is a fairly common question: how to put my business logic
The question is simple and to put it in just one line : The

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.