Awesome Open Source
Awesome Open Source

XRichText


XRichTextHtmlTextViewstarfork

XRecyclerView

step1

build.gradle

allprojects {
		repositories {
			...
			maven { url 'https://jitpack.io' }
	}
}

step2

dependencies {
	    compile 'com.github.limedroid:XRichText:v1.0.0'
}

:

texthtml

  • link
  • img
  • ()
  • urlwidthheight
  • universal image loaderPicassoGlide

  • spanned
  • ImageGetter

<cn.droidlover.xrichtext.XRichText
            android:id="@+id/richText"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:padding="16dp" />

Java

richText
                .callback(new XRichText.BaseClickCallback() {

                    @Override
                    public boolean onLinkClick(String url) {
                        showMsg(url);
                        return true;
                    }

                    @Override
                    public void onImageClick(List<String> urlList, int position) {
                        super.onImageClick(urlList, position);
                        showMsg(":" + position);
                    }

                    @Override
                    public void onFix(XRichText.ImageHolder holder) {
                        super.onFix(holder);
                        if (holder.getPosition() % 3 == 0) {
                            holder.setStyle(XRichText.Style.LEFT);
                        } else if (holder.getPosition() % 3 == 1) {
                            holder.setStyle(XRichText.Style.CENTER);
                        } else {
                            holder.setStyle(XRichText.Style.RIGHT);
                        }

                        //
                        holder.setWidth(550);
                        holder.setHeight(400);
                    }
                })
               .imageDownloader(new ImageLoader() {
                   @Override
                   public Bitmap getBitmap(String url) throws IOException {
                        return UILKit.getLoader().loadImageSync(url);
                   }
               })
                .text(TEXT);

api

  • onLinkClick(String url) urlurl
  • onImageClick(List urlList, int position) urlListurlposition0
  • onFix(XRichText.ImageHolder holder) holdersrcwidthheightstyle()
  • htmltext
  • imageDownloader(ImageLoader loader),UILPicassoImageLoadergetBitmaploader.
  • ClickCallbackBaseClickCallback,

: XDroid Android

Related Awesome Lists
Top Programming Languages
Top Projects

Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
Java (392,336
Step (21,698
Textview (1,200
Imageloader (448