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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:53:20+00:00 2026-05-28T00:53:20+00:00

I have a LinearLayout class in which I have: TexView | ImageView | EditText

  • 0

I have a LinearLayout class in which I have:

TexView | ImageView | EditText | ImageView.

I have the last ImageView all the way to the right side of the LinearLayout its wrapped in. The EditText runs very long and in some case pushes the last ImageView out of view (or so it seems to push it out of view).

I want to to have the EditText set to a percentage of the total width. I tried using weight with LinearLayout parameters but it seems to cause the view to get all out of wack. For example here it is for the EditText:

 LinearLayout.LayoutParams lpEt = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT,
                                                                             LinearLayout.LayoutParams.WRAP_CONTENT,
                                                                             .50f);

All the other views follow suit but have lesser weights (.2, .2, .1) and they all add up to 1.0. But the LinearLayout row is never spaced correctly.

Should I find out the width of the parent (which is a ListView) and then set the width of the EditText explicitly based on the parent’s width or is there a better way?

  • 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-28T00:53:20+00:00Added an answer on May 28, 2026 at 12:53 am

    Im not sure what your linear layout orientation is but im guessing its horizontal. if so try this.

    LayoutParams textViewParams = new LayoutParams(LayoutParams.WRAP_CONTENT,
            LayoutParams.WRAP_CONTENT);
    textView.setLayoutParams(textViewParams);
    LinearLayout.LayoutParams editTextParams = new LinearLayout.LayoutParams(
            0,LayoutParams.WRAP_CONTENT,1f);
    editText.setLayoutParams(editTextParams);
    LayoutParams imageViewParams = new LayoutParams(LayoutParams.WRAP_CONTENT,
            LayoutParams.WRAP_CONTENT);
    imageView.setLayoutParams(imageViewParams);
    

    This will make the edit text to fill the remaining space between the textview and imageview. If you need something else, just modify the code a bit. When using weights, set the weight or height as 0 for which you are setting weight for.

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

Sidebar

Related Questions

Can I have a class which extend a LinearLayout, as the main class of
I have a gridview in which there are two elements in each of its
I have extended my class with a dialog in which I have set content
I have an extended BaseAdapter that has LinearLayout children (an ImageView and a TextView
I have in my DBAdapter, a getAll which should pull all the data from
I have a ListView which contains an ImageView and a TextView. I'm subclassing ArrayAdapter
I have made a main Dialog class on which I send the layout ID
I have written a custom preference class which contains a simple progress bar in
So I have a fairly complex activity the parent being a linearlayout with a
I have the following XML layout for a ListActivity. <?xml version=1.0 encoding=utf-8?> <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android

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.