Skip to content

Android Library to load image from url inside <img> tag and adjust the image size.

Notifications You must be signed in to change notification settings

anggastudio/DynamicImageGetter

Repository files navigation

DynamicImageGetter

Android Library to load image from url inside img tag and adjust the image size.

License Pull request Twitter Github

Thanks to:

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.

Feature

  • 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)

Built With

  • Picasso - A powerful image downloading and caching library for Android

Contributing

Forget it. Just take the code, modify it, and make your own. But do not forget to thank rajeefmk.

License

What licence?

Download

Gradle

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

  • cek jitpack version to make sure you use the latest
dependencies {
  implementation 'com.github.anggastudio:DynamicImageGetter:2.0.0'
}

Maven

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>

Others Configuration

  • Make sure to use java 8+ configuration.
  • from release 2.0.0 androidX is used

Usage

  • 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);

About

Android Library to load image from url inside <img> tag and adjust the image size.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages