setOnKeyListener 를 사용하면 Enter key 처리가 제대로 되지 않음.
edittext.setOnEditorActionListener(new OnEditorActionListener(){
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if((actionId == EditorInfo.IME_ACTION_DONE)|| (event != null && event.getKeyCode() == KeyEvent.KEYCODE_ENTER)){
.....
}
return false;
}
});
============================
EditText Enter or Done Key 등 개발자가 원하는 대로 보여주고자 할 때
edittext.setImeOptions(EditorInfo.IME_ACTION_NEXT)
2011년 4월 18일 월요일
2011년 4월 15일 금요일
2011년 4월 1일 금요일
Bitmap 테두리 Rounding 처리
public class BitmapUtils {
private static final int ROUND_DIPS = 10;
public static Bitmap getRoundedCornerBitmap(Context context, Bitmap bitmap) {
Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Config.ARGB_8888);
Canvas canvas = new Canvas(output);
final int color = 0xff424242;
final Paint paint = new Paint();
final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());
final RectF rectF = new RectF(rect);
final float roundPx = convertDipsToPixels(context, ROUND_DIPS);
paint.setAntiAlias(true);
canvas.drawARGB(0, 0, 0, 0);
paint.setColor(color);
canvas.drawRoundRect(rectF, roundPx, roundPx, paint);
paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));
canvas.drawBitmap(bitmap, rect, rect, paint);
return output;
}
public static int convertDipsToPixels(Context context, int dips) {
final float scale = context.getResources().getDisplayMetrics().density;
return (int) (dips * scale + 0.5f);
}
}
private static final int ROUND_DIPS = 10;
public static Bitmap getRoundedCornerBitmap(Context context, Bitmap bitmap) {
Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Config.ARGB_8888);
Canvas canvas = new Canvas(output);
final int color = 0xff424242;
final Paint paint = new Paint();
final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());
final RectF rectF = new RectF(rect);
final float roundPx = convertDipsToPixels(context, ROUND_DIPS);
paint.setAntiAlias(true);
canvas.drawARGB(0, 0, 0, 0);
paint.setColor(color);
canvas.drawRoundRect(rectF, roundPx, roundPx, paint);
paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));
canvas.drawBitmap(bitmap, rect, rect, paint);
return output;
}
public static int convertDipsToPixels(Context context, int dips) {
final float scale = context.getResources().getDisplayMetrics().density;
return (int) (dips * scale + 0.5f);
}
}
피드 구독하기:
글 (Atom)