i have a problem with the ImageView. I want left of my TextView a ImageView with icon, but only have the height of the TextView. So it should scaled down, because the image is larger.
this is my code:
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="5dip" >
<LinearLayout
android:id="@+id/icon_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/name"
android:layout_alignTop="@+id/name" >
<ImageView
android:id="@+id/icon"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:contentDescription="@null"
android:scaleType="fitStart"
android:src="@drawable/m1" />
</LinearLayout>
<TextView
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/icon_container"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />
</RelativeLayout>
(works also without LinearLayout)
but this creates a gap between icon and text, as you see here:
now i really dont know how i can solve this. I also tried a LinearLayour with Icon and TextView within, but that also doesnt work.
EDIT:
i found no solution without code, but with code, i called:
ImageView icon = (ImageView)vi.findViewById(R.id.icon);
TextView name = (TextView)vi.findViewById(R.id.name);
name.measure(MeasureSpec.UNSPECIFIED,MeasureSpec.UNSPECIFIED);
name.setText("Test 1");
int height = name.getMeasuredHeight();
icon.getLayoutParams().height = height;
icon.getLayoutParams().width = height;