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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:53:42+00:00 2026-05-22T22:53:42+00:00

I am wondering why this happens : <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:orientation=horizontal android:layout_width=fill_parent android:gravity=center_vertical android:layout_height=wrap_content android:layout_gravity=top

  • 0

I am wondering why this happens :

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal" android:layout_width="fill_parent"
    android:gravity="center_vertical"
    android:layout_height="wrap_content" android:layout_gravity="top"
    android:background="@drawable/gradient" android:focusable="true"
    android:paddingTop="5dip" android:paddingBottom="5dip"
    android:focusableInTouchMode="true">
        <EditText android:id="@+id/searchField"
            android:layout_width="wrap_content" android:layout_height="fill_parent"

            android:paddingTop="2dip" android:paddingBottom="2dip"
            android:paddingLeft="10dip" android:paddingRight="10dip"
            android:inputType="textVisiblePassword" android:radius="5dip"
            android:layout_marginLeft="10dip"
            android:background="@drawable/search_background" android:textColor="#000000" />

        <Button android:id="@+id/info" android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dip"
            android:background="@drawable/info_btn" />
</LinearLayout>

If I set “fill_parent” to my EditText’s layout_width, it takes the whole width of the parent and the button disappears (I guess it is hidden below the EditText).

Can anybody explain me? I would like to get the Button takes its own width and the EditText takes the remaining width.

  • 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-22T22:53:42+00:00Added an answer on May 22, 2026 at 10:53 pm

    Your telling the EditText to fill_parent, therefore it fills the screen (the whole width, leaving no space for your button).

    You want the button to wrap its content and the edit text to fill the remainder, you can do this using layout_weight property:

    <?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="wrap_content"
     android:layout_gravity="top"
     android:gravity="center_vertical"
     android:paddingTop="5dip"
     android:paddingBottom="5dip"
     android:orientation="horizontal">
    <EditText
        android:id="@+id/searchField"
        android:layout_width="0dip"
        android:layout_height="fill_parent"
        android:layout_weight="1"
        android:layout_marginLeft="10dip"
        android:paddingTop="2dip"
        android:paddingBottom="2dip"
        android:paddingLeft="10dip"
        android:paddingRight="10dip"
        android:radius="5dip"
        android:inputType="textVisiblePassword"
        android:textColor="#000000" />
    <Button
        android:id="@+id/info"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="10dip"
        android:text="Blah" />
    </LinearLayout>
    

    (I took your drawable references out to make it generic for other people)

    On a side not to make your XML look nice an neat and more maintainable in eclipse:

    Window > Preferences > XML > XML Files > Editor

    Line width 120

    Split multiple attributes TICK

    Align final bracket UNTICK

    Preserve Whitespace tags in PCDATA UNTICK

    Clear all blank lines UNTICK

    Insert Whitespace before closing TICK

    Click ok

    Then you can fix your XML files, when you have an XML file open CTRL+A then CTRL+SHIFT+F will format it nicely!

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

Sidebar

Related Questions

I'm wondering if anyone knows how this happens? My website is down, but every
I was wondering whether this effect is a known problem or it happens only
I was just wondering why this certain problem happens to me. If you can
I'm wondering if this is actually a bug in the Android API: I have
I have a remote repository http://github.com/fernandezpablo85/Test This repo has a master branch, but it's
I've been wondering this for a while but since it hasn't come up much
I've been wondering this for some time. As the title say, which is faster,
Wondering if this is possible. We have an 3rd Party library that contains identification
Just wondering is this kind of code recommended to increase performance? void functionCalledLotsofTimes() {
I'm wondering if this is a good design. I have a number of tables

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.