JonZarate
JonZarate

Reputation: 871

Android: bring View to the front of a Dialog

EDIT:

Current effect: image current

Desired effect: image desired

Note

First of all, I tried bringToFront but it didn't work as expected.

Explanation

When a Dialog is shown the background gets darker, I guess it's due to a new Fragment with a translucent black background being placed on top of the Activity.

In our Activity there is an ImageButton that we want the User to see. We show a Dialog explaining what the ImageButton is for, but we also want it not to be affected by the Dialog shadow. It's like a tutorial message.

Future consideration

Also, please keep in mind that we will also transform the View (sizewise).

iOS

My workmate made it easily in iOS with bringToFront and some transformations.

Thanks

I haven't been able to do it in Android and haven't been able to successfully search it on Google neither Stack Overflow.

I think it's clear but I can provide an image later today if needed. Bye!

Upvotes: 2

Views: 1055

Answers (2)

JonZarate
JonZarate

Reputation: 871

I had no other choice, but to create an Activity, put it on top and place another ImageView in the same spot, so that it covers the one behind.

To do so, I had to pass the ImageView position and size to the new Activity and place it correctly at onCreate.

Upvotes: 1

Mohammad Ahsan
Mohammad Ahsan

Reputation: 60

In your resources.xml file, add a new entry:

<style name="Theme.DoNotDim" parent="android:Theme">
<item name="android:backgroundDimEnabled">false</item>
</style>

and then simply use this theme for your activity by changing the manifest file.

<activity android:name=".YourActivity" android:theme="@style/Theme.DoNotDim">

Already answered here by chuky

Upvotes: 0

Related Questions