0
我需要帮助才能让我的图像和文本的布局工作。Android,布局图像和文本
我希望图像缩放到与我的TextView使用的高度相同。 我还希望图像留给文本。 例如#
在我的图像
# "My Text"
或
## "My long text
## is this here"
图像的witdh将会使图像保持方面。
我的代码是现在这个,基本的布局工作,但形象是大。
<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="==================="
/>
编辑1
A以外的尝试给我相同的结果。
<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
我现在已经找到了一半的工作代码,这里的问题是图像的宽度为原点的宽度,而不是新的规模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>