Hi, I want to create this sort of a view where there should be a center image view and others overlapping it and i want it to be clickable. How can I achieve this?
Asked
Active
Viewed 603 times
1
-
I think it can be done only programmatically. – Sergey Shustikov Sep 24 '15 at 20:45
-
Any snippet , would be a great help – Amresh Sep 24 '15 at 20:47
-
I'll take a guess here and say that with the new material design approach it can be done since views have a Z property to them – Daniel Mendel Sep 24 '15 at 21:19
-
There are a lot of potential solutions. Like Daniel said, if you're targeting Lollipop+, you could try 6 FABs with one eleveated above. For some reason, I think you can do this with PopWindow. You could write a custom View, or views. You could make a custom gesture detector to put on top of an ImageView. – a person Sep 24 '15 at 22:41
-
http://stackoverflow.com/questions/13861416/android-custom-shape-button – karan Sep 25 '15 at 11:27
1 Answers
0
You should be able to make it using just RelativeLayout and ImageView.
RelativeLayout lets you overlap views and position it anyway you want.
For getting the touches you can set OnClickListeners to each of the images.
Example:
RelativeLayout rl = new RelativeLayout(this);
ImageView img1 = new ImageView(this);
//Set imageView bitmap
img1.setDrawable("Img");
//Click of the image
img1.setOnClickListener(new View.OnClickListener(){...});
//Size of the image
RelativeLayout.LayoutParams prms = new RelativeLayout.LayoutParams(width,height);
//Rules for position the view on screen
prms.addRule(...)
//Add image to layout
rl.addView(img1,prms);
setContentView(rl);
Z order is the order items are added to the layout.
Hope this helps.

Nanoc
- 2,381
- 1
- 20
- 35