海蘭,我不知道如何將這個XML,因爲我需要它的代碼代碼
<RelativeLayout
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>
放置就是這樣。 我的一切至今
gi = new RelativeLayout(this);
gi.setBackgroundResource(R.raw.gi);
img1= new ImageView(this);
img1.setImageResource(R.drawable.b1);
img1.setLayoutParams();
img2= new ImageView(this);
img2.setImageResource(R.drawable.b2);
img3= new ImageView(this);
img3.setImageResource(R.drawable.b3);
gi.addView(img1,64,64);
gi.addView(img2,64,64);
gi.addView(img3,64,64);
我顯然遇到一些麻煩,我不能在文檔中找到alignparents。同樣是這些像素,DPI的或者在addview東西
謝謝,但我仍然無法找到這個layout_to_right_of沒有使用imageview r.id,如果我將它們全部添加像這樣,他們堆疊在另一個之上 – user1398593
好的,這裏也許是一個更好的鏈接:http://stackoverflow.com/questions/5191099/how-to-set-relativelayout-layout-params-in-code-not-in-xml。請注意,我認爲它只是需要id,以便知道如何在視圖之間建立關係,因爲這就是relativeLayout的工作原理。當然,我可能是錯的,但根據API看起來這樣。 –
也不是真的有幫助,我之所以想這樣做的原因是將它添加到glsurface視圖。我需要添加到XML以使其工作以及如何啓動我的GLSurfaceView? – user1398593