Reputation: 195
I am trying to create a demo application in which i want to create a image view which is overlapped with each other with slight change in x and y coordinates (similar to any card game in which all cards are overlapped with each other but we can see the numbers). and if user touch on the card then all the cards should expand so that user should be the content on cards.
I have tried frame layout and relative layout but in both cases images are always overlapped with each other completely..
If you have any suggestion please share.
Below is the source code for adding image view to relative layout by java
ImageView myView = new ImageView[10];
for (int i = 0; i < myView.size(); i++) {
myView [i] = new ImageView(context);
myView [i].setImageBitmap(getImg(i));
}
RelativeLayout headFrame = new RelativeLayout(getApplicationContext());
headFrame.setLayoutParams(new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.WRAP_CONTENT,
RelativeLayout.LayoutParams.WRAP_CONTENT));
RelativeLayout.LayoutParams imageViewParams = new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.WRAP_CONTENT,
RelativeLayout.LayoutParams.WRAP_CONTENT
);
for (int i = 0; i < myView.size(); i++) {
//imageViewParams.setMargins(50, 50, 0, 0);
//imageViewParams.leftMargin = 40;
imageViewParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
imageViewParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
myView[i].setLayoutParams(imageViewParams);
headFrame.addView(myView[i]);
}
Upvotes: 1
Views: 950
Reputation: 4816
You want to use a layer list see this: http://developer.android.com/guide/topics/resources/drawable-resource.html#LayerList
You're welcome :)
Upvotes: 2