当我在一个特定的XML文件中运行的布局,我得到这样的:
When I run layout on a specific XML file, I get this:
This tag and its children can be replaced by one <TextView/>
and a compound drawable
什么变化应为下面的XML code来完成:
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 like on the screen:
摄像机图标是默认的。点击这将带给用户一个选项,选择另一个图像。
The camera icon is the default. Clicking on that will give the user an option to choose another image.
合并的TextView
和的ImageView
成之一,通过使用TextView中的 setCompoundDrawable *()
的方法,或者使用机器人:drawableLeft
Merge the TextView
and the ImageView
into one, by using TextView's setCompoundDrawable*()
methods, or using android:drawableLeft
.