答案 0 :(得分:2)
可以通过编程实现:
fun TextView.setIconifiedText(text: String, @DrawableRes iconResId: Int) {
SpannableStringBuilder("$text#").apply {
setSpan(
ImageSpan(context, iconResId, DynamicDrawableSpan.ALIGN_BOTTOM),
text.length,
text.length + 1,
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
)
}.let {
setText(it)
}
}
textView.setIconifiedText(
"First line text that is longer.\nSecond line text.",
R.drawable.ic_android_black_24dp
)
答案 1 :(得分:0)
您需要使用android:drawableEnd
答案 2 :(得分:0)
将它们都放置在相对布局中并添加
android:layout_toEndOf="<id of first view>"
进入自定义视图