Android ImageGetter images overlapping text

后端 未结 5 1397
一个人的身影
一个人的身影 2020-12-01 04:14

I\'m trying to load a block of HTML into a TextView, including images, using

URLImageParser p = new URLImageParser(articleBody, this);
Spanned htmlSpan = Ht         


        
5条回答
  •  感动是毒
    2020-12-01 04:34

    You could change your cointainer c (view) to a textView and then make your onPostExecute look like this:

    @Override 
    protected void onPostExecute(Drawable result) { 
        // set the correct bound according to the result from HTTP call 
        Log.d("height",""+result.getIntrinsicHeight()); 
        Log.d("width",""+result.getIntrinsicWidth()); 
        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();
    
        // For ICS
        URLImageParser.this.container.setHeight((URLImageParser.this.container.getHeight() 
        + result.getIntrinsicHeight()));
    
        // Pre ICS
        URLImageParser.this.textView.setEllipsize(null);
    } 
    

    This will first draw the image and then immediately set the height of the TextView to the drawable's height + the TextViews height

提交回复
热议问题