[android/Layout] FrameLayout 사용방법
- Mobile/android
- 2013. 1. 7.
Think
- ㅡㅡ 설정이란 것이 많아 질 수록. 간단한 부분에서 Error 발생 및 삽질이 점점 많아져 간다. ㅋ
목표
- 현재 Android Camera 위에 또다른 layout 을 시용하여서 Drawing 의 간섭을 받지 않고 그리도록 하는 것.
Layout 3층 : InterfaceView
Layout 2층 : OpenGL
Layout 1층 : Android Camera View
이렇게 하였다 싶을 때, 각각의 층에대한 interaction 을 만들고 싶은데 안될 때가 있다. 뭐 그건 나중에 정리하도록 하자.
어찌되었던. layout 을 넣기위한 방법을 보도록 하자.
by 퓨림노
문제점.
-
<xml> File - 조금 보기 어려운 문제점이 있네요. 원래 들여쓰기가 안되어있는거라..
추가되는 <java> File
package org.opencv.samples.tutorial3;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.view.View;
public class InterfaceView extends View {
/*
* public InterfaceView(Context context, AttributeSet attrs) {
* super(context, attrs); // TODO Auto-generated constructor stub }
*/
public InterfaceView(Context context) {
super(context);
// TODO Auto-generated constructor stub
}
public void onDraw(Canvas canvas) {
Paint paint = new Paint();
paint.setColor(Color.TRANSPARENT);
paint.setAlpha(150);
int width = canvas.getWidth();
int height = canvas.getHeight();
canvas.drawRect(100, 100, width - 100, height - 100, paint);
String str = "Canvas Test";
paint.setTextSize(20);
canvas.drawText(str, 150, 150, paint);
}
}
최종 생성자 설정
public InterfaceView(Context context, AttributeSet attrs) {
super(context, attrs); // TODO Auto-generated constructor stub }
}
위의 생성자 처럼 (Context context, AttributeSet attrs) 를 시용하여야 XML 에서 Load 가 되니 필수 확인하도록 하자.
'Mobile > android' 카테고리의 다른 글
| [Android] openCV build using NDK on Android Studio (2) | 2021.01.26 |
|---|---|
| [android] activity_main_out.xml 파일생성 에러 (0) | 2013.01.07 |
| JNI Native Load Module (0) | 2012.12.05 |
| [Android] 작업하면서~ 메모 (0) | 2012.12.04 |
| Unable to resolve target 'android-11' until the SDK is loaded (0) | 2012.11.19 |