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>
I has finally found a working way, not very good but work for me.
My code is now
And the
mypacket.MyImageViewis this code.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.