textview.setText 和 textview.append 的图像
image with textview.setText and textview.append
我需要一些帮助。我有一个屏幕,其中有一个文本视图。在文本视图中,我检查了一些条件并将一些文本附加到该文本视图。我想要的是在每一行的左侧插入一个图像。这是一个单一的文本视图。就像下面一样。我怎样才能做到这一点?谢谢
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
的每一侧放置一个可绘制对象。 (即底部、顶部、左侧、右侧),作者 setCompoundDrawablesWithIntrinsicBounds(...)
您的情况的一个选项是使用垂直 LinearLayout
并将这些 TextView 添加为其子项。这些也可以通过上述方法在其左侧放置一个可绘制对象。
在 layout.xml 文件中使用以下代码
android:drawableLeft="@drawable/page1"(可绘制资源)
您可以使用此属性在 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
的每一侧放置一个可绘制对象。 (即底部、顶部、左侧、右侧),作者 setCompoundDrawablesWithIntrinsicBounds(...)
您的情况的一个选项是使用垂直 LinearLayout
并将这些 TextView 添加为其子项。这些也可以通过上述方法在其左侧放置一个可绘制对象。
在 layout.xml 文件中使用以下代码
android:drawableLeft="@drawable/page1"(可绘制资源)
您可以使用此属性在 textview 的任何一侧设置图像。