336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.
요즘 Motorola, LG 에서도 안드로이드 폰을 국내에서 출시하며,
IPhone 대항마의 역할로써 안드로이드 폰이 어느 정도 자리를 잡아가고 있는 것 같습니다.
TV만 보고 있어도 하루에도 여러 번씩 SKT 안드로이드 폰 광고를 볼 수도 있기도 하구요.
때문에 오늘은 안드로이드에 대한 재밌는 상식 하나를 소개할까 합니다.

아시는 분도 계시겠지만, Android 플랫폼의 버젼명은 디저트 종류 음식 이름을 애칭으로 가지고 있습니다.
최초 버젼인 1.5 는 Cupcake(컵케익), 1.6 은 Donut(도넛), 최근의 2.0 버젼이후 2.1까지는 Eclair(이클레어) 라고 불리고 있죠.
2010년 5월경 출시될 다음버젼 이름은 Froyo(프로요 : Frozen Yogurt)가 확정된 상태입니다.


Froyo 의 다음 버젼은 Gingerbread(진저브레드)라는 것도 거의 확정인 상태 이지요.

 

딱 보고 감이 오시나요?

Cupcake
Donut
Eclair
Froyo
Gingerbread

Cupcake 을 시작으로 Android Version 닉네임의 제일 첫 글자는 알파벳 순서로 증가하고 있습니다.
아마 Gingerbread 다음 버젼은 H 로 시작하는 디저트 이름이 닉네임으로 붙게 되겠지요? H 로 시작하는 디저트가 뭐가 있을까요? 
H 로 시작하는 음식 이름도 Hotdog, Hamburger 를 제외하면 딱히 생각이 안나는 군요... ^^
여러분들이 한 번 맞춰 보도록 하세요~

아래는 구글의 PM 인 Ryan Gibson 이 라디오 방송에서 얘기한 Andorid Version 에 대한 이야기 입니다.

Q: How did Android versions come to be named after desserts?
A: We wanted an alphabetical naming scheme that would also provide a fun theme for our small release celebrations.  We considered predatory animals, and stomach viruses but they are a lot less fun to have at a party.

Q: What were the "A" and "B" desserts? Apple crumb? Babka?
A: There actually were no "A" and "B" software updates named after a dessert. It just started with Cupcake.

Q: Who determines the dessert names?
A: It's a collaborative effort from the entire team, company, spouses, Google chefs, random passer-bys and the Android development community all throwing out ideas and recipes.  My office door is festooned with suggestions for the future.  It is very motivational to look up from work and see pictures of tasty treats.

Q: Are the desserts actually served at the Google cafeteria at any point?
A: Absolutely!

Q: Have you determined any desserts past "F"?
A: The discussion is as heated as an oven full of cupcakes  We would like to have a Gingerbread House, but that depends a lot on what happens with the housing market by then. 

 

※ 일반적으로 Phone의 버젼명에 의미 없는 숫자나 날짜를 기반으로 한 버젼명을 사용하는데요. 
힘든 개발 환경속에서의 이런 사소한 잔 재미를 찾고 만들어 실행하는 것이 구글의 창의적인 결과물의 원동력의 일부라고 봐도 되겠지요??

※ 이런식의 작명법은 Ubuntu 의 Project가 원조라고 하네요.



블로그 이미지

By훈트

,
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.
Android 에서 EditText 에 문자를 입력하다보면 특정 키에 대한 처리를 하고싶을 때가 있다.
예를 들면,

아이디와 비밀번호 등을 입력한뒤 Enter 키의 입력시 한줄 내려쓰가 된다
이것을 처리하는 코드를 간단하게 작성해봤다.


onKey 이벤트를 catch하여 입력된 keyCodeevent.KEYCODE를 비교하여 해당 key입력 시 특정 처리를 할수 있다.

return true; 대신 구현하고싶은 코드를 작성하면 된다.
블로그 이미지

By훈트

,
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.
계속 속썩여온 비율 문제...
아이폰은 가로 세로 사이즈라도 고정되어 있지만..
안드롱은 지 맘대로니..어떻게 해서든 비율 문제를 풀어야 했다.
계속 끙끙거리다 드디어 정리됨 -_-;;

리스트의 한 로우는 2줄로 구성되어 있다.
첫번째 줄은 3칸, 두번째 줄은 1칸이고 첫번째 줄으니 비율은 1:1:2 이다.
이 에 대한 코드는 다음과 같다.

 
 <?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical">
    
    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content">
        
        <TextView android:id="@+id/wordlist_row_level"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:background="#66CCFF"
            android:textSize="20px"            
            android:gravity="center"/>
    
        <TextView android:id="@+id/wordlist_row_word"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:background="#FF9900"
            android:textSize="20px"/>
            
        <TextView android:id="@+id/wordlist_row_date"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="2"
            android:background="#FFCCFF"
            android:textSize="20px"
            android:gravity="center"/>            
    </LinearLayout>
        
    <TextView android:id="@+id/wordlist_row_meaning"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="#00FF00"
        android:textSize="20px"
        android:gravity="center"/>        
</LinearLayout>

android:layout_width를 fill_parent나 wrap_content로 주면 안된다.
반드시 "0dp" 로 정해주자.
그리고 비율은 android:layout_weight 로 정해주면 된다.

[출처] [Android] layout 비율|작성자 로사


블로그 이미지

By훈트

,
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

 

리소스에서 bitmap을 읽어오고 화면에 출력한 후 touch를 이용해서 drag하는 예제

package com.jjihun.bitmaptest;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;

public class BitmapView extends View {
 Bitmap bitmap;
 int width;
 int height;
 int dx;
 int dy;
 public BitmapView(Context context, AttributeSet attrs) {
  super(context, attrs);

  bitmap = BitmapFactory.decodeResource(context.getResources(), R.drawable.yuandi);
  // 얘 뒤져보면 byte[] 에서 bitmap생성하는 것도 있심

  width = bitmap.getWidth();
  height = bitmap.getHeight();
 }

 @Override
 protected void onDraw(Canvas canvas) {
  canvas.drawBitmap(
     bitmap, // 출력할 bitmap
     new Rect(0,0,width,height),   // 출력할 bitmap의 지정된 영역을 (sub bitmap)
     new Rect(dx,dy,dx+width,dy+height),  // 이 영역에 출력한다. (화면을 벗어나면 clipping됨)
     null);

  super.onDraw(canvas);
 }

 @Override
 public boolean onTouchEvent(MotionEvent event) {
  
  switch(event.getAction()) {
  case MotionEvent.ACTION_DOWN:
   break;
  case MotionEvent.ACTION_UP:
   break;
  case MotionEvent.ACTION_MOVE:
// 주루룩 drag했을 경우 히스토리가 모두 기록되어서 전달됨
   int length=event.getHistorySize();
   float sx, sy, ex, ey;
   
   if (length != 0) {
    sx = event.getHistoricalX(0);
    sy = event.getHistoricalY(0);
    ex = event.getHistoricalX(length-1);
    ey = event.getHistoricalY(length-1);

    dx += (int)(ex-sx);
    dy += (int)(ey-sy);
   }
   invalidate();
   break;
  }
  
  return true;
 }
}


블로그 이미지

By훈트

,
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

1) 비율을 정확히 고정시키고 싶을 때는

자체 테이블을 그리거나 할 때 TableLayout을 사용하면 알아서 늘어나고 줄어드는 컬럼 때문에 정신건강에 좋지 않다. 이럴 때는 LinearLayout을 이용해서 android:layout_width를 0px로 변경하고, weight로 비율을 고정하면 늘어나고 줄어들지 않게 고정시킬 수 있다. 정확히 나뉜 컬럼이 필요하거나 할 때는 이 방법을 이용한다. 단, 이렇게 나뉘는 영역에는 당연하겠지만 margin이 포함되지 않으니 margin을 함부로 사용하면 어그러진다. padding을 잘 활용해야 한다.

 

  1. android:layout_width="0px"
    android:layout_height="wrap_content"
  2. android:layout_weight="0.25"

 

블로그 이미지

By훈트

,
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.
안 드로이드에는 얼굴 인식 기능이 내장되어 있습니다. FaceDetector Class가 바로 이미지를 분석하여 얼굴을 찾아내는 역할을 하는 클래스입니다. 얼굴 인식 기능은 이미지를 사용하는 다양한 애플리케이션에서 활용 가능 하고 간단히 사용할 수 있으므로 참고하세요.

FaceDetector.Face[] faces = new FaceDetector.Face[10];     // 최대 인식할 얼굴수 설정
FaceDetector detector = new FaceDetector(bitmap.getWidth(), bitmap.getHeight(), faces.length);
int numFaces = detector.findFaces(bitmap, faces);     // 얼굴 인식 실행
for(FaceDetector.Face face : faces) {
    PointF midPoint = new PointF();
    face.getMidPoint(midPoint);            //눈과 눈사의 가운데 지점
    float eyesDistance = face.eyesDistance();    //눈과 눈사이의 거리
    //처리.
}

더 많은 샘플 소스는 아래의 사이트들을 참고하세요.
- http://d.hatena.ne.jp/bols-blue/20090818/1250562668
- http://blog.livedoor.jp/deeds_not_words/archives/624855.html
- http://www.anddev.org/quick_and_easy_facedetector_demo-t3856.html


펌 : http://www.androidpub.com/android_dev_info/22845
블로그 이미지

By훈트

,
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.
 
  1. CustomView의 생성과정은 점,선,면의 생성과정과 동일하다
  2. Sample ( Canvas에 출력하기 / Canvas에 궤적추적출력 활용 )
  3. Path는 drawPath, drawTextOnPath와 같이 궤적을 따라 출력하기 위한 객체이다
  4. 벡터정보를 저장하고 궤적을 출력하는등 활용도가 다양하다
  5. 관련 메서드
    1. void addArc(RectF oval, float startAngle, float sweepAngle) : 호의 추가
    2. void addCircle(float x, float y, float radius, Path.Direction dir) : 원의 추가
    3. void addOval(RectF oval, Path.Direction dir)  : 타원의 추가
    4. void addPath(Path src, Matrix matrix) : 행렬이 적용되는 Path의 추가
      1. (Path src)
      2. (Path src, float dx, float dy)
    5. void addRect(RectF rect, Path.Direction dir) : 사각형 추가
      1. (float left, float top, float right, float bottom, Path.Direction dir)
    6. void addRoundRect(RectF rect, float[] radii, Path.Direction dir) :모따진 사각형추가
      1. (RectF rect, float rx, float ry, Path.Direction dir)
    7. void arcTo(RectF oval, float startAngle, float sweepAngle, boolean forceMoveTo)  : 호의 추가
      1. (RectF oval, float startAngle, float sweepAngle)
    8. void close() : 현 궤적의 종료
    9. void computeBounds(RectF bounds, boolean exact) : Path point의 영역산출
    10. void cubicTo(float x1, float y1, float x2, float y2, float x3, float y3) : 베지어 공식의 곡선  
      1. rCubicTo(float x1, float y1, float x2, float y2, float x3, float y3) : 상대좌표사용       
    11. Path.FillType getFillType()  : 현 Path 채우기모드의 반환
    12. void incReserve(int extraPtCount) : Hint to the path to prepare for adding more points.
    13. boolean isEmpty() : 정보가 없는 경우 true를 반환
    14. boolean isInverseFillType()  : 반대변형이 가능한가를 판단
    15. boolean isRect(RectF rect) : 영역의 정보가 사각형인가를 판단
    16. void lineTo(float x, float y) : 마지막 Path에서 선그리기 추가
      1. rLineTo(float dx, float dy)  : 상대좌표 사용
    17. void moveTo(float x, float y) : 좌표이동 추가
      1. rMoveTo(float dx, float dy) : 상대좌표사용
    18. void offset(float dx, float dy) : Offset the path by (dx,dy), returning true on success
      1. (float dx, float dy, Path dst)
    19. void quadTo(float x1, float y1, float x2, float y2)  :
      1. Add a quadratic bezier from the last point, approaching control point (x1,y1), and ending at (x2,y2).
      2. rQuadTo(float dx1, float dy1, float dx2, float dy2) : 상대좌표사용
    20. void reset() : Path정보를 Empty로 만들기
    21. void rewind() : 라인, 커브는 지우고, 내부정보는 다시 사용하는 방법
    22. void set(Path src) : 정보의 수정
    23. void setFillType(Path.FillType ft) : 채우기 지정
    24. void setLastPoint(float dx, float dy) : 최종좌표의 변경
    25. void toggleInverseFillType() : 채우기의 반대모드로 변환하기
    26. void transform(Matrix matrix) : 행렬로 변형하기
      1. transform(Matrix matrix, Path dst)
  6. 사용 순서
    1. public void onDraw(Canvas canvas)에서 사용
      1. Path path = new Path();
      2. Paint paint = new Paint(); // Path출력도 Paint의 정보에 준한다
      3. paint정보 Setting 하기
      4. path정보 만들기
      5. canvas.drawPath( path, paint ) // Path 출력하기
        1. canvas.drawTextOnPath( string, path, 0, 0, paint) // 곡선, 원등에 문자출력하기
블로그 이미지

By훈트

,