当我在特定的XML文件上运行布局时,我得到了这个:
This tag and its children can be replaced by one <TextView/>
and a compound drawable
Run Code Online (Sandbox Code Playgroud)
应对以下xml代码进行哪些更改:
<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>
Run Code Online (Sandbox Code Playgroud)
这就是它在屏幕上的样子:

相机图标是默认设置.单击该按钮将为用户提供选择其他图像的选项.
NPi*_*ike 144
为了扩展Romain Guy的答案,这是一个例子.
之前:
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:padding="5dp" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="My Compound Button" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/my_drawable" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
后:
<TextView
android:layout_marginTop="10dp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="My Compound Button"
android:drawableRight="@drawable/my_drawable" android:padding="5dp" />
Run Code Online (Sandbox Code Playgroud)
Rom*_*Guy 101
通过使用TextView的方法或使用将TextView其合并ImageView为一个.setCompoundDrawable*()android:drawableLeft
| 归档时间: |
|
| 查看次数: |
43226 次 |
| 最近记录: |