서명하는 부분을 만들고 있는데, 뒷 배경이있어서 이미지뷰를 사용했습니다.
레이아웃은
<RelativeLayout
android:id="@+id/sign_btn_layout01"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="128dp">
<LinearLayout
android:id="@+id/sign_btn_layout02"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:id="@+id/sign_img"
android:layout_width="fill_parent"
android:layout_height="157dp"
android:src="@drawable/sign"/>
<Button
android:id="@+id/btn_sign_again"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_marginTop="2dp"
android:background="@drawable/set_btn_retry_sign" />
</LinearLayout>
</RelativeLayout>
이렇게 되어 있구요.
소스상에서는
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.sign_activity);
canvas = new Canvas();
signPaint = new Paint();
signPaint.setAntiAlias(true);
signPaint.setDither(true);
signPaint.setColor(Color.BLACK);
signPaint.setStyle(Paint.Style.STROKE);
signPaint.setStrokeWidth(12);
/** 화면 표현 관련 초기 설정 및 표현 */
setDisplay();
/** 이벤트 관련 등록 및 초기 설정 */
setEventListener();
}
으로 만들어 져있습니다. 이벤트 리스너 안에서 이미지뷰.onTouchListener(this); 를 했구요.
그리고
@Override
public void onWindowFocusChanged(boolean hasFocus) {
// TODO Auto-generated method stub
super.onWindowFocusChanged(hasFocus);
width=signView.getWidth();
height=signView.getHeight();
Log.e("heightttt",""+height);
Log.e("Widthhhh",""+width);
}
public boolean onTouch(View v, MotionEvent event) {
int action = event.getAction();
switch (action) {
case MotionEvent.ACTION_DOWN:
downx = event.getX();
downy = event.getY();
break;
case MotionEvent.ACTION_MOVE:
break;
case MotionEvent.ACTION_UP:
upx = event.getX();
upy = event.getY();
canvas.drawLine(downx, downy, upx, upy, signPaint);
signView.invalidate();
break;
case MotionEvent.ACTION_CANCEL:
break;
default:
break;
}
return true;
}
이렇게 작성했는데, 로그에
02-26 01:12:51.631: E/AndroidRuntime(10234): Caused by: java.lang.ClassCastException: android.widget.LinearLayout cannot be cast to android.widget.ImageView
이렇게 뜹니다.
아 도대체 뭐가 잘못되어있는지 모르겠어요ㅠㅠㅠㅠㅠㅠ....
도움 좀 꼭 부탁드려요ㅠㅠㅠㅠ