0

It should look like this:

It should look something like this

I'm specifically using android studio. I currently have a textview and my text in the strings.xml file, but I understand there are other ways of doing the code. I have several paragraphs to write, so I figured this would be the best place to insert the text. I will need to include an image, a button, and links straight into the sentences I'm writing. (Any advice for each of those would be helpful) But, my first issue is that I don't know how to add the image into the middle of the sentence. All relevant posts are incomplete or outdated.

Taslim Oseni
  • 6,086
  • 10
  • 44
  • 69

3 Answers3

0

To achieve this you need to use setCompoundDrawablesWithIntrinsicBounds() method of TextView. Heopfully this will help you. Or you can use **SpannableStringBuilder ** for this to get. I hope this will help you.

UPDATED: Here sample is available. I am attaching link as well. It will help you in your implementation

https://stackoverflow.com/questions/15352496/how-to-add-image-in-a-textview-text
Abdul Waheed
  • 4,540
  • 6
  • 35
  • 58
  • 1
    Man... the documentation on the usage for this seems too vague. Maybe it's too complex for me to understand. I do appreciate your help though. – Curious Cat Mar 22 '19 at 18:07
  • I saw this post before asking for help. It's not useful for me as I don't understand it. I can't tell which implementation is for what, some of them weren't relevant, and some didn't have useful enough comments to tell if the referenced code was relevant or useful. But, I do appreciate your help. – Curious Cat Mar 23 '19 at 19:02
0

I would suggest if you wish to display large amount of text then use something like WebView with some html template engine.

vavasthi
  • 922
  • 5
  • 14
0

I have implemented this type of code in my app but I was used dependency which I describe here...

Implement this dependency in your build.gradle file

implementation 'org.sufficientlysecure:html-textview:4.0'

and then write this line in your build.gradle(Root level) or on the settings.gradle file

repositories {
        jcenter()
    }

Layout.xml

<org.sufficientlysecure.htmltextview.HtmlTextView
                android:id="@+id/textView"
                android:textAppearance="@android:style/TextAppearance.Small"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:textColor="@color/black"
                android:textSize="13dp" />

In your Activity.java file in OnCreate Method

TextView textView;

textView = (TextView) itemView.findViewById(R.id.textView);
textView.setHtml("<b>Hello</b> this is my Text <span/> <img src="yourimage.jpg"> <span/> Another Text, new HtmlHttpImageGetter(myHolder.question));