The Code is as follows:
Bitmap bitmap = mWebView. getFavicon ();
Drawable drawable = new BitmapDrawable (bitmap );
// Edit. setCompoundDrawables (drawable, null, null );
Drawable = this. getResources (). getDrawable (R. drawable. history );
Edit. setCompoundDrawablesWithIntrinsicBounds (drawable, null, null );
Edit. setText (cur_url );
// Edit. setMaxLines (1 );
Difference between setCompoundDrawablesWithIntrinsicBounds and setCompoundDrawables:
The width and height of The drawable drawn by setCompoundDrawables are The width and height set by drawable. setBound (). Therefore, The Drawables must already have had setBounds (Rect) called is available.
While setCompoundDrawablesWithIntrinsicBounds is the width and height of the drawn drawable. It is obtained by getIntrinsicWidth () and getIntrinsicHeight, therefore, The Drawables 'bounds will be set to their intrinsic bounds.
See the following method:
Public void setCompoundDrawablesWithIntrinsicBounds (Drawable left, Drawable top,
Drawable right, Drawable bottom ){
If (left! = Null ){
Left. setBounds (0, 0, left. getIntrinsicWidth (), left. getIntrinsicHeight ());
}
If (right! = Null ){
Right. setBounds (0, 0, right. getIntrinsicWidth (), right. getIntrinsicHeight ());
}
If (top! = Null ){
Top. setBounds (0, 0, top. getIntrinsicWidth (), top. getIntrinsicHeight ());
}
If (bottom! = Null ){
Bottom. setBounds (0, 0, bottom. getIntrinsicWidth (), bottom. getIntrinsicHeight ());
}
SetCompoundDrawables (left, top, right, bottom );