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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T21:02:28+00:00 2026-06-14T21:02:28+00:00

Here’s the thing: I have an EditText and a Button. The concept is to

  • 0

Here’s the thing:

I have an EditText and a Button. The concept is to have the EditText long so that it covers the Button, but the Button is on top. Let’s picture it this way, [] for EditText width, () for Button width.

[ EditText        ( Button )]

The Button is positioned on the right side within the EditText. Is it possible?
Any suggestions? Thanks.

  • 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-14T21:02:30+00:00Added an answer on June 14, 2026 at 9:02 pm

    you should create a custom view. Below example , there are a botton right of edittect, when you click it, it clear edittext.

    clearable_edit_text.xml

    <?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=”wrap_content”
    >
    
    <EditText
    android:id=”@+id/clearable_edit”
    android:layout_width=”fill_parent”
    android:layout_height=”wrap_content”
    android:paddingRight=”35dip”
    />
    <Button
    android:id=”@+id/clearable_button_clear”
    android:layout_width=”30dip”
    android:layout_height=”30dip”
    android:layout_alignParentRight=”true”
    android:background=”@drawable/image_clear”
    android:layout_centerVertical=”true”
    android:layout_marginRight=”5dip”/>
    
    </RelativeLayout>
    

    JAVA Code

    import android.content.Context;
    import android.text.Editable;
    import android.text.TextWatcher;
    import android.util.AttributeSet;
    import android.view.LayoutInflater;
    import android.view.View;
    import android.widget.Button;
    import android.widget.EditText;
    import android.widget.RelativeLayout;
    
    public class ClearableEditText extends RelativeLayout
    {
    LayoutInflater inflater = null;
    EditText edit_text;
    Button btn_clear;
    
    public ClearableEditText(Context context, AttributeSet attrs, int defStyle)
    {
    super(context, attrs, defStyle);
    // TODO Auto-generated constructor stub
    initViews();
    }
    
    public ClearableEditText(Context context, AttributeSet attrs)
    {
    super(context, attrs);
    // TODO Auto-generated constructor stub
    initViews();
    
    }
    
    public ClearableEditText(Context context)
    {
    super(context);
    // TODO Auto-generated constructor stub
    initViews();
    }
    
    void initViews()
    {
    inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    inflater.inflate(R.layout.clearable_edit_text, this, true);
    edit_text = (EditText) findViewById(R.id.clearable_edit);
    btn_clear = (Button) findViewById(R.id.clearable_button_clear);
    btn_clear.setVisibility(RelativeLayout.INVISIBLE);
    clearText();
    showHideClearButton();
    }
    
    void clearText()
    {
    btn_clear.setOnClickListener(new OnClickListener()
    {
    @Override
    public void onClick(View v)
    {
    // TODO Auto-generated method stub
    edit_text.setText(“”);
    }
    });
    }
    
    void showHideClearButton()
    {
    edit_text.addTextChangedListener(new TextWatcher()
    {
    
    @Override
    public void onTextChanged(CharSequence s, int start, int before, int count)
    {
    // TODO Auto-generated method stub
    if (s.length() > 0)
    btn_clear.setVisibility(RelativeLayout.VISIBLE);
    else
    btn_clear.setVisibility(RelativeLayout.INVISIBLE);
    }
    
    @Override
    public void beforeTextChanged(CharSequence s, int start, int count, int after)
    {
    // TODO Auto-generated method stub
    
    }
    
    @Override
    public void afterTextChanged(Editable s)
    {
    // TODO Auto-generated method stub
    
    }
    });
    }
    
    public Editable getText()
    {
    Editable text = edit_text.getText();
    return text;
    }
    }
    

    So now our Customized view ClearableEditText is ready now we can use it wherever we need it.
    like

    <?xml version=”1.0″ encoding=”utf-8″?>
    <LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android”
    android:layout_width=”fill_parent”
    android:layout_height=”fill_parent” >
    
    <com.and.ab1209.ClearableEditText
    android:id=”@+id/edit_text_clearable”
    android:layout_width=”fill_parent”
    android:layout_height=”wrap_content” />
    
    </LinearLayout>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's a coding problem for those that like this kind of thing. Let's see
Here's what I'm trying to accomplish with this program: a recursive method that checks
Here's my problem I have this javascript if (exchRate != ) { function roundthecon()
Here is what I want to do. Use this HTML line and have the
Here is the problem that I am trying to solve. I have two folders
Here's the basic setup: I have a thin bar at the top of a
Here is the problem I'm trying to solve for my game. I have this
Here is my scenario. I have a website running under AppPool1 and that works
Here's the code I have. It works. The only problem is that the first
Here's a basic regex technique that I've never managed to remember. Let's say I'm

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.