android-在文本视图中设置文本部分的背景图像

android-在文本视图中设置文本部分的背景图像,android,textview,background-image,Android,Textview,Background Image,我想在android中实现一本带有一些选项的书。其中之一是在文本的部分背景中设置图片。我该怎么做 谢谢设置文本视图背景 android:background="@drawable/imgsrc" 在XML文件中使用以下代码 <TextView android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android

我想在android中实现一本带有一些选项的书。其中之一是在文本的部分背景中设置图片。我该怎么做


谢谢

设置文本视图背景

android:background="@drawable/imgsrc"

在XML文件中使用以下代码

<TextView
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/yourImageName"
    />

尝试此操作,并根据您的要求修复imageview的右侧

 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <ImageView
        android:id="@+id/image"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

    <TextView
        android:id="@+id/text"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

</RelativeLayout>


使用复合文本视图。android:background=“@drawable/image”我想设置文本视图的图像部分,但不是所有的itI都不是这个意思。我必须将图像设置为文本的一部分。例如最后两个字符