Displaying emoticons in Android

I think it would be more useful to build Spannable. private static final Factory spannableFactory = Spannable.Factory .getInstance(); private static final Map<Pattern, Integer> emoticons = new HashMap<Pattern, Integer>(); static { addPattern(emoticons, “:)”, R.drawable.emo_im_happy); addPattern(emoticons, “:-)”, R.drawable.emo_im_happy); // … } private static void addPattern(Map<Pattern, Integer> map, String smile, int resource) { map.put(Pattern.compile(Pattern.quote(smile)), resource); } public static … Read more

Android Drop Shadow on View

You could use a combination of Bitmap.extractAlpha and a BlurMaskFilter to manually create a drop shadow for any image you need to display, but that would only work if your image is only loaded/displayed once in a while, since the process is expensive. Pseudo-code (might even compile!): BlurMaskFilter blurFilter = new BlurMaskFilter(5, BlurMaskFilter.Blur.OUTER); Paint shadowPaint … Read more

Android – ImageView: setImageBitmap VS setImageDrawable

There is no difference between the two internally setImageBitmap is calling setImageDrawable. Below code is picked from ImageView.java of AOSP public void setImageBitmap(Bitmap bm) { // if this is used frequently, may handle bitmaps explicitly // to reduce the intermediate drawable object setImageDrawable(new BitmapDrawable(mContext.getResources(), bm)); }