如何将链接转换为附加图像?

时间:2017-12-04 09:04:22

标签: android

enter image description here

这叫什么?

如何实施?

有没有Lib / API?

1 个答案:

答案 0 :(得分:1)

此功能称为 Rich Link

使用Android Link Preview Library

可以轻松实现富链接

通过在gradle中添加以下内容来实现

添加以下存储库

repositories {
  jcenter()
  maven { url 'https://github.com/leonardocardoso/mvn-repo/raw/master/maven-deploy' }
}

添加以下gradle文件

compile 'org.jsoup:jsoup:1.8.3' // required
compile 'com.leocardz:link-preview:2.0.0@aar'

如果您使用的是Proguard规则,请添加以下规则

-keeppackagenames org.jsoup.nodes

实施

<强> Intialisation

import com.leocardz.link.preview.library.TextCrawler;
// ...
// Create an instance of the TextCrawler to parse your url into a preview.
TextCrawler textCrawler = new TextCrawler();

// ..

// Create the callbacks to handle pre and post exicution of the preview generation.
LinkPreviewCallback linkPreviewCallback = new LinkPreviewCallback() {
    @Override
    public void onPre() {
        // Any work that needs to be done before generating the preview. Usually inflate 
        // your custom preview layout here.
    }

    @Override
    public void onPos(SourceContent sourceContent, boolean b) {
        // Populate your preview layout with the results of sourceContent.
    }
};

生成预览

textCrawler.makePreview( linkPreviewCallback, url);

请试试这个

Here is Another Library.