Android: How to display image in text view

While designing we may get a situation where we may have to display a image near text. For example  


In Android, to display like this, we may use a Imageview followed by a Textview.


Drawable drawable= activity.getResources().getDrawable(R.drawable.lyb);//load image in drawable
drawable.setBounds(0,0,drawable.getIntrinsicWidth(),calRich.getIntrinsicHeight());//sepecify bounds
textView.setCompoundDrawables(null,null,calRich,null);//right image
textView.setCompoundDrawablePadding(5);// specify padding between image and text


Share on Google Plus

About Nice

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment