我需要一些帮助。我有一个屏幕,其中有一个 TextView 。在 TextView 中,我检查了一些条件并将一些文本附加到该 TextView 。我想要的是在每一行的左侧插入一个图像。这是一个单一的 TextView 。就像下面一样。我怎样才能做到这一点?谢谢。
tv.setText("image here","\nAccount: " + booking.getAccount());
tv.append("image here",String.format("\t(Vehicle Type: %s)",booking.getVehicletype()));
tv.append("image here","\n\nTag: " + booking.getTag());
tv.append("image here","\n\nDate & Time: " + booking.getDate() + " - " + booking.getTime());
tv.append("image here","\n\nName: " + booking.getCustname());
最佳答案
i want is to insert an image on the left of each line
你不能这样做。您只能在 TextView
的每一侧放置一个 drawable。 (即底部、顶部、左侧、右侧),通过 setCompoundDrawablesWithIntrinsicBounds(...)
您的情况的一个选项是使用垂直 LinearLayout
并将这些 TextView 添加为其子项。这些也可以通过上述方法在其左侧放置一个可绘制对象。
关于java - 带有 textview.setText 和 textview.append 的图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32715010/