Take view position on the screen and apply in another view

Asked

Viewed 139 times

2


I’m trying to make a transition effect when I open a DialogFragment but for that I need the photo(CircleImageView) of DialogFragment is in the same place as the photo of Activity which opens it. If it is not clear I will explain with the images:

inserir a descrição da imagem aqui

This is the image I want to use as a positioning base for the other DialogFragment. Clicking on this photo opens an DialogFragment with this screen:

inserir a descrição da imagem aqui

Disregard the buttons, my focus is just the image. How do I position this image in exactly the same place as the other programmatically?

  • 1

    First I thought: if the second image has a white background, why doesn’t it create an image the size of the first one with a white background? Then I thought: how to ensure that the first image will always be in the same place depending on the various screen resolutions between the devices?

  • Exactly, I could not recreate the same layout because the first is a header of a Drawerlayout and would not end up in the same proportions.

  • This link shows you how to position the image. I don’t know how to guarantee that the first image will always be in the same place. http://stackoverflow.com/questions/6418726/android-setting-x-y-of-image-programmatically http://stackoverflow.com/questions/6535648/how-can-i-dynamically-set-the-position-of-view-in-android http:///stackoverf.com/questions/19328756/set-position-programmatically-created-imageview-android

  • First you would have to center according to the device, so that in the fragment remain centralized.

  • I want to position the second photo according to the first and not the other way around.

  • @Brunoromualdo then, try to position your photo inside a LinearLayout, then you use this Linear in his fragment.

  • Just understand that there is no way to put the two in the same position using xml, so at the end of the question is written programmatically.

Show 2 more comments

1 answer

1

  • But you can (and even should) contextualize and exemplify your response, so that the links are just a reference. Responses only with links are not very well accepted on the site.

  • And an example of usage, you can add?

  • Hello @Anderson, I once saw this library but I didn’t use it because I don’t have an example of how to use it in a DialogFragment, like the @Diegofm I said Do not have an example? would help a lot.

  • Now that you’ve taken a look at the documentation this saying that only works from the Lollipop up, it’s no use.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.