tags:

views:

33

answers:

1

When I run layoutopt on a specific xml file, I get this:

 This tag and its children can be replaced by one <TextView/> 
and a compound drawable

What change should be done for the following xml code:

<LinearLayout android:id="@+id/name_layout"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:gravity="center_vertical"
                android:background="@drawable/grouplist_single_left_grey_area" >
                <ImageView android:id="@+id/photo_image"
                    android:layout_width="@dimen/thumbnail_width"
                    android:layout_height="@dimen/thumbnail_height"
                    android:paddingBottom="5dip"
                    android:paddingTop="5dip"
                    android:paddingRight="5dip"
                    android:paddingLeft="5dip"
                    android:layout_marginRight="5dip"
                    android:clickable="true"
                    android:focusable="true"
                    android:scaleType="fitCenter"
                    android:src="@*android:drawable/nopicture_thumbnail"
                    android:background="@drawable/photo_highlight" />
                <TextView android:id="@+id/name"
                    android:paddingLeft="5dip"
                    android:layout_weight="1"
                    android:layout_width="0dip"
                    android:layout_height="wrap_content"
                    android:gravity="center_vertical"
                    android:textAppearance="?android:attr/textAppearanceLarge" />
            </LinearLayout>

This is how it looks on the screen:

http://img13.imageshack.us/img13/6293/screenqg.jpg

The camera icon is the default. Clicking on that will give the user an option to choose another image.

+1  A: 

Merge the TextView and the ImageView into one, by using TextView's setCompoundDrawable*() methods, or using android:drawableLeft.

Romain Guy
@Romain Guy : Could you point me to an example illustrating how that can be done? I am not sure how all the attributes in the ImageView can be accommodated in android:drawableLeft.Thank you
Dilip
I have also posted an image of how it looks on the screen. Could you also look at this question that I posted sometime back? http://stackoverflow.com/questions/3113501/false-positives-while-running-layoutopt-for-android
Dilip