rajeefmk for his PicassoImageGetter. I got the idea to retrieve the image from html using Picasso and put it inside TextView in Android Studio. Then I added some code to adjust the image size dynamically.
- Load remote urls from
<img>
tag when loaded inside android<TextView/>
- Adjust the image size to :
- as tall as line height (auto width)
- as wide as
<TextView/>
width with padding (auto height) - or as is (without size adjustment)
- Picasso - A powerful image downloading and caching library for Android
Forget it. Just take the code, modify it, and make your own. But do not forget to thank rajeefmk.
What licence?
Step 1. Add it in your root build.gradle at the end of repositories:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
Step 2. Add the dependency
dependencies {
implementation 'com.github.anggastudio:DynamicImageGetter:2.0.0'
}
Step 1.
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
Step 2. Add the dependency
<dependency>
<groupId>com.github.anggastudio</groupId>
<artifactId>DynamicImageGetter</artifactId>
<version>1.0</version>
</dependency>
- Make sure to use java 8+ configuration.
- from release 2.0.0 androidX is used
- Load image with size as tall as line height (auto width)
String htmlString = DummyTextHtml.htmlString;
TextView textView = findViewById(R.id.textView);
DynamicImageGetter.with(this)
.load(htmlString)
.mode(DynamicImageGetter.INLINE_TEXT)
.into(textView);
- Load image with size as wide as
<TextView/>
width with padding (auto height)
String htmlString = DummyTextHtml.htmlString;
TextView textView = findViewById(R.id.textView);
DynamicImageGetter.with(this)
.load(htmlString)
.mode(DynamicImageGetter.FULL_WIDTH)
.into(textView);
- Load image with size or as is (without size adjustment)
String htmlString = DummyTextHtml.htmlString;
TextView textView = findViewById(R.id.textView);
DynamicImageGetter.with(this)
.load(htmlString)
.into(textView);