Git Product home page Git Product logo

richtext's Introduction

RichText

Android平台下的富文本显示TextView

  • 支持Html格式文本
  • 支持图片点击事件
  • 链接自动回调
  • 支持设置加载中和加载错误时的图片
  • 支持自定义超链接的点击回调
  • 加入了修正图片宽高的方法(感谢foolchen

加入了自定义超链接点击回调

text.setOnURLClickListener(new RichText.OnURLClickListener() {
   @Override
   public boolean urlClicked(String url) {
        Toast.makeText(getApplicationContext(), url, Toast.LENGTH_SHORT).show();
        return true;// 返回true表示已处理,false会继续调用默认得处理方法
   }
});

注意此方法需在setRichText方法之前调用

修正图片宽高的方法

text.setImageFixListener(new RichText.ImageFixListener() {
     @Override
     public void onFix(RichText.ImageHolder holder) {
           if (holder.getWidth() > 100 || holder.getHeight() > 100) {
                int width = getScreenWidth(getApplicationContext());
                int height = (int) (holder.getHeight() * 1f * width / holder.getWidth()) - 300;
                holder.setWidth(width);
                holder.setHeight(height);
                holder.setScaleType(RichText.ImageHolder.CENTER_INSIDE);
           }
     }
});

也需要在setRichText方法之前调用

gradle中引用的方法

compile 'zhou.widget:richtext:1.0.4'

具体使用请查看demo

演示

by zzhoujay

richtext's People

Contributors

zzhoujay avatar

Watchers

James Cloos avatar dorin avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.