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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:09:11+00:00 2026-06-13T09:09:11+00:00

I need help for get my layout of a image and text to work.

  • 0

I need help for get my layout of a image and text to work.

I want the image to scale to be the same height my TextView take in use.
I want also the image to be left to the text.
For in example # is my image

# "My Text"

or

## "My long text
## is this here"

The witdh of the image will be so the image keep the aspects.

My code is now this, the basic layout work but the image is to big.

        <LinearLayout 
            android:id="@+id/packet_list_view_layout_subvehicle" android:layout_width="fill_parent"
            android:layout_weight="1" android:orientation="horizontal"
            android:gravity="left" android:layout_height="wrap_content">
            <ImageView 
                android:id="@+id/packet_list_view_layout_subvehicle_image"
                android:src="@drawable/packet"
                android:scaleType="fitCenter"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />
            <TextView
                android:id="@+id/packet_list_view_layout_subvehicle_text"
                android:textAppearance="?android:attr/textAppearanceSmall"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="==================="
                />

EDIT 1

A other try that give me the same result.

        <LinearLayout
            android:id="@+id/packet_list_view_layout_subvehicle"
            android:layout_width="fill_parent"
            android:layout_weight="1"
            android:orientation="horizontal"
            android:gravity="left"
            android:layout_height="wrap_content"
        >
            <ImageView
                android:id="@+id/packet_list_view_layout_subvehicle_image"
                android:layout_width="wrap_content"
                android:layout_height="fill_parent"
                android:scaleType="fitCenter"
                android:src="@drawable/packet" />
            <TextView
                android:id="@+id/packet_list_view_layout_subvehicle_text"
                android:layout_width="wrap_content"
                android:layout_height="fill_parent"
                android:text="TV's (20) to London"
                android:textAppearance="?android:attr/textAppearanceSmall" />
        </LinearLayout>

EDIT 2

I has now found a half working code, the problem here is the width of the image is the origin width and not the new scale witdh.

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:id="@+id/packet_list_view_layout_subvehicle"
        >
            <ImageView
                android:id="@+id/packet_list_view_layout_subvehicle_imageAA"
                android:layout_width="wrap_content"
                android:layout_height="fill_parent"
                android:src="@drawable/packet"
                />

            <TextView
                android:id="@+id/packet_list_view_layout_subvehicle_text"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:gravity="center|left"
                android:text="TV's (20) to London"
                android:textAppearance="?android:attr/textAppearanceSmall" />
        </LinearLayout>
  • 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-13T09:09:12+00:00Added an answer on June 13, 2026 at 9:09 am

    I has finally found a working way, not very good but work for me.

    My code is now

            <LinearLayout
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal"
                android:id="@+id/packet_list_view_layout_subvehicle"
            >
                <mypacket.MyImageView
                    android:id="@+id/packet_list_view_layout_subvehicle_imageAA"
                    android:layout_width="wrap_content"
                    android:layout_height="fill_parent"
                    android:src="@drawable/packet"
                    />
    
                <TextView
                    android:id="@+id/packet_list_view_layout_subvehicle_text"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:gravity="center|left"
                    android:text="TV's (20) to London"
                    android:textAppearance="?android:attr/textAppearanceSmall" />
            </LinearLayout>
    

    And the mypacket.MyImageView is this code.

    public class MyImageView extends ImageView {
    
        public MyImageView(Context context) {
            super(context);
        }
        public MyImageView(Context context, AttributeSet attrs) {
            super(context, attrs);
        }
        public MyImageView(Context context, AttributeSet attrs, int defStyle) {
            super(context, attrs, defStyle);
    
        }
        @Override
        protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
            super.onMeasure(heightMeasureSpec, heightMeasureSpec);
        }
    }
    

    EDIT: In true, I don’t use this, base one some error with how the system calc the size, that do the image will be bigger then need, and this will do the text to warp to two lines. In final I use a normal ImageView and set fix hegth and withd.

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

Sidebar

Related Questions

I need help to get a response when I click on an Item from
Need your help to get the max of CAP_PRICE based on certain criteria in
I need some help to get this right, please. I have created an iPad
I need help regarding JOIN tables to get category name & author name from
i got some problem and need help .. my plan : 1. get ip
I need a little help here: I get a file from an HTML upload
Hi I need a little help: How to get profile URL given an UID?
I need some help, and before we get going, I know it is probably
I would need little help here. I'm trying to get the git respository from
I need a little help with navigating a json file. I'm looking to get

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.