Android - TextView添加图片

来源:互联网 发布:超链接执行js 编辑:程序博客网 时间:2024/05/22 07:59

TextView添加图片


本文地址:http://blog.csdn.net/caroline_wendy


Android UI设计时,经常需要在文字周围添加图片

比较简单的方法是直接使用Layout把View组合到一起:

<ImageView     android:layout_width=“wrap_content"     android:layout_height="wrap_content"     android:src="@drawable/icon_home_askdoc"     android:scaleType="fitXY"     android:layout_above="@+id/asking_doctor"     android:layout_centerHorizontal="true"/>
ImageView,适配图片大小,填充"scaleType:fitXY",视图的水平居中"centerHorizontal:true"。

也可以直接在TextView的周围添加图片(drawable):
<TextView     style="@style/HomepageGridMenuTextStyle"     android:drawablePadding="8dp"     android:drawableTop="@drawable/icon_home_avatar"     android:text="@string/home_avatar"/>
TextView,drawableTop在文字上面添加图片,但是无法调节图片的属性







2 0