Android用Kotlin语言设置 TextView中图文混合排列
2017-07-05 16:47
405 查看
1.设置需要显示的文字和图片:
var s:String = "haha"+ "<img src='" + R.mipmap.login_account + "'/>"2.获取ImageGetter
fun getImageGetter():Html.ImageGetter{ var imgGetter:Html.ImageGetter =object: Html.ImageGetter { override fun getDrawable(p0: String): Drawable { var fontH:Int = (resources.getDimension(R.dimen.login_textSize14)*1.5).toInt() var id = Integer.parseInt(p0) var d:Drawable = resources.getDrawable(id) var height:Int = fontH var width:Int = (( d.getIntrinsicWidth().toFloat() / d .getIntrins
et_account.setText(Html.fromHtml(s, getImageGetter(),null))
icHeight().toFloat()) * fontH).toInt() if (width == 0) { width = d.getIntrinsicWidth() } d.setBounds(0, 0, width, height) return d } } return imgGetter }
3.将内容显示在TextView中
et_account.setText(Html.fromHtml(s, getImageGetter(),null))相关文章推荐
- Android用Kotlin语言设置 TextView中图文混合排列
- Android TextView图文混合编排
- Android UI之TextView实现图文混合效果
- Android TextView图文混合编排
- Android TextView中有图片有文字混合排列
- Android TextView实现图文混合编排的方法
- android中TextView设置字体竖直排列
- Android TextView图文混合编排
- Android TextView中有图片有文字混合排列
- Android TextView图文混合编排
- 【工作笔记】android TextView、EditText对部分内容设置颜色、字体、超链接、图片
- android中TextView中如何设置水平滚动效果
- android:为TextView添加样式——下划线,颜色,设置链接样式及前背景色
- Android实战技巧:用TextView实现Rich Text---在同一个TextView中设置不同的字体风格
- Android实战技巧:用TextView实现Rich Text---在同一个TextView中设置不同的字体风格
- Android TextView中文字设置超链接、颜色、字体
- Android TextView中文字设置超链接、颜色、字体
- android中TextView中如何设置水平滚动效果
- android background设置颜色后就成textview了
- Android中TextView中的字体大小能设置吗?