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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:51:45+00:00 2026-05-25T12:51:45+00:00

I have a linearlayout with 2 image views and a text view. I want

  • 0

I have a linearlayout with 2 image views and a text view. I want proper space distribution within the layout row. It should be somethink like below

______________________________
|IV|                       |IV|
|  | <-- Text View ----->  |  |
_______________________________

How can I achieve this? I want all the space assigned to textview after fitting the two images.

Below is my attempt and its not working.

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout android:orientation="horizontal"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent" android:layout_below="@+id/addTrip"
    android:layout_weight="1" android:layout_height="wrap_content">

    <ImageView android:layout_width="wrap_content"
        android:layout_height="wrap_content" android:layout_gravity="left"
        android:src="@drawable/icon" />
    <TextView android:layout_weight="1" android:id="@+id/textView1"
        android:clickable="true" android:layout_width="0dp"
        android:layout_height="wrap_content" android:gravity="right"
        android:text="Enter trip name"></TextView>
    <ImageView android:id="@+id/imageView1"
        android:layout_gravity="right" android:src="@drawable/edit"
        android:layout_width="wrap_content" android:layout_height="wrap_content"></ImageView>
</LinearLayout>

I am using this as Layout inflater.

 ArrayList<TripInfo> trips = inst.getListOfTrips(); //reading from DB


        for (int i =0; i < trips.size(); i++) {
            TripInfo tobj = trips.get(i);
            LayoutInflater vi = (LayoutInflater) getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            LinearLayout lrow = (LinearLayout)vi.inflate(R.layout.triprow, null);
           ((TextView)lrow.getChildAt(1)).setText(tobj.getName());
           placeHolderLinearLayout.addView(lrow);
        }

Experts please provide some input. Do I have to set anything in the code as well.

  • 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-25T12:51:45+00:00Added an answer on May 25, 2026 at 12:51 pm

    Both image views should have: android:layout_width="wrap_content" and no android:layout_weight specified.

    And the central TextView should have android:layout_width="0dp" and android:layout_weight="1".


    In fact it doesn’t matter if you have 1 or any other value specified as weigght. As long as this is the only view that has layout_weight it takes up all free space. So you can easily fix you example just by removing android:layout_weight="0.2" in last ImageView.

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

Sidebar

Related Questions

I have a list view with an image view and text in a linear
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
I have a linear layout with this form <?xml version=1.0 encoding=utf-8?> <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:orientation=vertical
I have this nice dialog view I set my UserInputDialog class to: <LinearLayout android:id=@+id/LinearLayout01
Okay, so I have a JSON array of image URLs. I want to load
I have an xml layout which places an image at the top of the
I want to create a layout like below.. This is the XML i have
Let's say i have a layout with style: <LinearLAyout ... > <TextView ... style=someStyle
I have a Horizontal Layout in which some vertical layouts are dispatched. I want
I have a custom toast notification which has an image and text. The custom

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.