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>