이미이 질문을 Relative layout Coding에 요청했지만이 시도는 확실하지 않았습니다.OpenGL 및 Android 관련 레이아웃
나는 GLSurfaceView
을 통해 상대 레이아웃을 만들 싶지만 레이아웃은 다음과 같이해야합니다
<RelativeLayout
android:id="@+id/View1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@raw/gi"
android:orientation="vertical" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="64px"
android:layout_height="64px"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:src="@drawable/b1" />
<ImageView
android:id="@+id/imageView2"
android:layout_width="64px"
android:layout_height="64px"
android:layout_alignParentTop="true"
android:layout_toRightOf="@+id/imageView1"
android:src="@drawable/b2" />
<ImageView
android:id="@+id/imageView3"
android:layout_width="64px"
android:layout_height="64px"
android:layout_alignParentTop="true"
android:layout_toRightOf="@+id/imageView2"
android:src="@drawable/b3" />
</RelativeLayout>
그러나, 나는 그것을 코딩하는 경우가 작동 답을 말처럼하지만 이미지가 여전히 넣어 서로의 상단. (나는 getld 함수를 addrules에 사용했다.)
그래서 전체 XML 파일을 추가하고 그런 식으로 작업 할 생각이지만 xml을로드하면 app이 멈춘다. 마음에 마지막 호출하지 않고 addContentView
앱 작동
public class HelloWorld extends Activity {
...
protected void onCreate(Bundle savedInstanceState) {
....
opengl = new GLSurfaceView(getApplication());
opengl.setEGLConfigChooser(new GLSurfaceView.EGLConfigChooser() {
public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display) {
int[] attributes = new int[] { EGL10.EGL_DEPTH_SIZE, 16, EGL10.EGL_NONE};
EGLConfig[] configs = new EGLConfig[1];
int[] result = new int[1];
egl.eglChooseConfig(display, attributes, configs, 1, result);
return configs[0];
}
});
renderer = new MyRenderer();
mGLView.setRenderer(renderer);
setContentView(opengl);
addContentView(findViewById(R.id.View1), new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.FILL_PARENT,
RelativeLayout.LayoutParams.FILL_PARENT));
곰 : 여기에 대부분의 코드입니다.
내 자신의 질문에 답변 할 것 같습니다. addcontentview 대신 다음을 추가했습니다. gi = new RelativeLayout (this); 보기보기; LayoutInflater inflater = (LayoutInflater) getApplicationContext(). getSystemService (Context.LAYOUT_INFLATER_SERVICE); view = inflater.inflate (R.layout.gi, null); hud.addView (보기); \t \t addContentView (gi, new ViewGroup.LayoutParams (ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); – user1398593
그리고 그와 같이 glsurface 뷰 위에 전체 XML 파일을 추가하는 데 성공했습니다. 하지만 지금은 r.layout.gi에서 각 어린이의 ID를 얻는 방법에 대해 궁금합니다. R.id.imageView1의 그림을 바꾸고 싶다고하자. ?????????????? (특별 감사 http://stackoverflow.com/questions/2335813/how-to-inflate-one-view-with-an-layout) – user1398593
댓글은 답변이 아닙니다. 자신의 질문에 대답하고 싶다면 실제로 페이지 하단의 "답변 게시"버튼을 사용하여 * 대답 *하십시오. –