title: Android HTML in textView, images size
body: <p>i need to implement textview with HTML, and normally images.
  I used code, that found here:
  <a href="https://stackoverflow.com/questions/15617210/android-html-fromhtml-with-images">Android HTML.fromHTML() with images?</a></p>
  
  <p><strong>URLDrawable.java</strong></p>
  
  <pre><code>public class URLDrawable extends BitmapDrawable {
      // the drawable that you need to set, you could set the initial drawing
      // with the loading image if you need to
      protected Drawable drawable;
  
      @Override
      public void draw(Canvas canvas) {
          // override the draw to facilitate refresh function later
          if(drawable != null) {
              drawable.draw(canvas);
          }
      }
  }
  </code></pre>
  
  <p><strong>URLImageParser.java</strong></p>
  
  <pre><code>public class URLImageParser implements ImageGetter {
      Context c;
      View container;
  
      /***
       * Construct the URLImageParser which will execute AsyncTask and refresh the container
       * @param t
       * @param c
       */
      public URLImageParser(View t, Context c) {
          this.c = c;
          this.container = t;
      }
  
      public Drawable getDrawable(String source) {
          URLDrawable urlDrawable = new URLDrawable();
  
          // get the actual source
          ImageGetterAsyncTask asyncTask = 
              new ImageGetterAsyncTask( urlDrawable);
  
          asyncTask.execute(source);
  
          // return reference to URLDrawable where I will change with actual image from
          // the src tag
          return urlDrawable;
      }
  
      public class ImageGetterAsyncTask extends AsyncTask&lt;String, Void, Drawable&gt;  {
          URLDrawable urlDrawable;
  
          public ImageGetterAsyncTask(URLDrawable d) {
              this.urlDrawable = d;
          }
  
          @Override
          protected Drawable doInBackground(String... params) {
              String source = params[0];
              return fetchDrawable(source);
          }
  
          @Override
          protected void onPostExecute(Drawable result) {
              // set the correct bound according to the result from HTTP call
              urlDrawable.setBounds(0, 0, 0 + result.getIntrinsicWidth(), 0 
                      + result.getIntrinsicHeight()); 
  
              // change the reference of the current drawable to the result
              // from the HTTP call
              urlDrawable.drawable = result;
  
              // redraw the image by invalidating the container
              URLImageParser.this.container.invalidate();
          }
  
          /***
           * Get the Drawable from URL
           * @param urlString
           * @return
           */
          public Drawable fetchDrawable(String urlString) {
              try {
                  InputStream is = fetch(urlString);
                  Drawable drawable = Drawable.createFromStream(is, "src");
                  drawable.setBounds(0, 0, 0 + drawable.getIntrinsicWidth(), 0 
                          + drawable.getIntrinsicHeight()); 
                  return drawable;
              } catch (Exception e) {
                  return null;
              } 
          }
  
          private InputStream fetch(String urlString) throws MalformedURLException, IOException {
              DefaultHttpClient httpClient = new DefaultHttpClient();
              HttpGet request = new HttpGet(urlString);
              HttpResponse response = httpClient.execute(request);
              return response.getEntity().getContent();
          }
      }
  }
  </code></pre>
  
  <p>Here I'm setting my textview text:</p>
  
  <pre><code>URLImageParser parser = new URLImageParser(textView, getActivity());
  Spanned spanned = Html.fromHtml(myArticle.getDescription(), parser, null);
  textView.setText(spanned);
  </code></pre>
  
  <p>But i'm getting images too small:</p>
  
  <p><a href="https://i.stack.imgur.com/xckOX.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xckOX.jpg" alt="enter image description here"></a></p>
  
  <p>If i changing <code>drawable.setBounds(0, 0, 500(just example), 500(just example))</code></p>
  
  <p>I'm getting image with this problem:</p>
  
  <p><a href="https://i.stack.imgur.com/yCXyI.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yCXyI.jpg" alt="enter image description here"></a></p>
  
  <p>I have just beginned my way in android, help me please.</p>