I am working in An Android App in which Relative layout is
<ImageView
android:id="@+id/imageView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop="2dp"
android:adjustViewBounds="true"
android:background="@drawable/background" />
<RelativeLayout
android:id="@+id/mymainlayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
>
</RelativeLayout>
my problem is I am unable to Draw all ImageViews programatically in this Relative Layout it is showing only one image. Here is my code
for (int i = 0; i < realAnswer; i++) {
arrayofImages[i] = new ImageView(this);
arrayofImages[i].setImageResource(imageId[imageNumber]);
arrayofImages[i].setId(i);
if(i!=0)
{
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
params.addRule(RelativeLayout.LEFT_OF, arrayofImages[i-1].getId());
//arrayofImages[i].setLayoutParams(params);
nn.addView(arrayofImages[i],params);
}
else
{
nn.addView(arrayofImages[i]);
}
}
here nn is my main layout
any help Please ???