有什么办法可以将图像放在TextView的最后一行
我使用setCompoundDrawablesWithIntrinsicBounds
。关于它的一些想法会很好。
此外,我只需要处理对我的图像的点击。此行为由以下代码表示:
textView.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.info, 0);
textView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if(event.getAction() == MotionEvent.ACTION_UP) {
if(event.getRawX() >= textView.getRight() - textView.getTotalPaddingRight()){
listener.onAddressClicked(livingAreas);
return true;
}
}
return true;
}
});
最佳答案
使用 TextView ,您可以在确定的位置设置可绘制对象。
您可以使用此 xml 示例:
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableBottom="@drawable/image"
android:text="blablabla"/>
以编程方式:
public void setCompoundDrawables(Drawable left, Drawable top, Drawable right, Drawable bottom)
text_view.setCompoundDrawables(null, null, null, getDrawable(drawable_image_id));
关于java - TextView 在最后一行设置图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46684329/