D
D
Denis2016-09-01 00:07:28
Android
Denis, 2016-09-01 00:07:28

How to overlay view on view in android?

Good day to all.
There is a task in which it is necessary that the user can select a picture and it immediately starts uploading to the server, on the application screen it is necessary to show a thumbnail of the picture with a progress bar superimposed on it (just on it, and not next to it or on the whole screen), so that the user can fill in other fields while the pictures are loading.
From the ideas that came to my mind: put the progress bar below the image and drag it with a negative margin top.
And the second option is to put them in one RalativeLayout and bind them to the top of the parent element.
However, I consider such approaches to be some perversions and I would like to know if there are other more correct methods to place one view element on another.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
Denis Zagaevsky, 2016-09-01
@zagayevskiy

Putting in one FrameLayout is the cheapest solution. RelativeLayout is overkill in this case.

S
Sergey Semenko, 2016-09-01
@abler98

RelativeLayout + android:layout_centerInParent="true"

T
Tiberal, 2016-09-01
@Tiberal

FrameLayout as mentioned above. You can even try to get by with only FrameLayout and ImageView. Draw a progress bar in xml and attach it to the frame using android:foreground

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question