How to bring a view to the front and keep other views behind it in Android?


Syed Hassan

I'm trying to make an android app so that when I click on a particular view, it will be brought to the front of each view, leaving the other views to stay behind it, so that the colors get a little dull. For example: this whatsapp profile shows the layout. (The config file is at the top of everything and we can interact with it)

I would like to know the relevant keyword, topic or name of a specific widget to learn to finally implement that view along with animation. Any way to reach a solution would also be appreciated.

I've tried other ways to bring the image to the front, etc. But that doesn't solve the problem.

Pramod Moolekandathil

You can achieve this by creating a custom alert dialog and inflating a layout into it.

public class CvvHelpDialog extends Dialog {

    public CvvHelpDialog(@NonNull Activity context) {
        super(context);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.dialog_cvv_help);

        WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
        lp.copyFrom(getWindow().getAttributes());
        lp.width = WindowManager.LayoutParams.MATCH_PARENT;
        getWindow().setAttributes(lp);

    }
}

For R.layout.dialog_cvv_help, you can design a layout as your requirement. You can display it by simply using the below lines of code.

CvvHelpDialog cvvDialog = new CvvHelpDialog(getActivity());
cvvDialog.show();

Related


View is hidden behind other views in android activity

android_newbie I'm trying to load an image fullscreen and place two button bars (one at the top and one at the bottom). But when I test the app, the top bar is hidden by the whole image, while the bottom bar is displayed correctly. <?xml version="1.0" encoding

How to add a view behind other views in iOS

Denis Kutlubaev I would like to add a view under the tab bar analogy in iOS and then display it with an animation behind it. However, when I use the code, the view that has to come from behind the tab bar overlaps the tab bar for a while. Here is my code: - (v

How to add a view behind other views in iOS

Denis Kutlubaev I would like to add a view under the tab bar analogy in iOS and then display it with an animation behind it. However, when I use the code, the view that has to come from behind the tab bar overlaps the tab bar for a while. Here is my code: - (v

How to add a view behind other views in iOS

Denis Kutlubaev I would like to add a view under the tab bar analogy in iOS and then display it with an animation behind it. However, when I use the code, the view that has to come from behind the tab bar overlaps the tab bar for a while. Here is my code: - (v

Bring View in Front of Image View - Android XML

username I have several issues with the layout in an activity. Here is what I currently have: As you can see, the green circle is below the header image, even though it should overlap on top. Also, as you can see, the text to the right of the circle is below t

How to animate image view behind other image view in android

Nihasmata I have the following two images (plus and multiply): When the "plus" image is clicked, the "multiply" image starts the transition animation from the same position as the "plus" image and goes to the last image The end of the screen shown my problem i

Bring a view to the front in Swift

Yevgeny Kleban I have 2 views and I need to add and remove another view on certain conditions. The problem is that when I add two views, set constraints and hide the ones I don't need, it breaks the gestures to the other views. Is there any easy way to bring a

How to bring an Android suspended activity to the front

Rick McConney I have an activity that starts an async task that listens for messages from the server. When the user clicks the Home button, the activity will pause and the async task will continue to run in the background. When a certain message arrives, I wan

How to edit views hidden behind other views in Xcode Storyboard?

Patrick Patrick Is there an easy way in Xcode to edit views that are hidden behind other views in a Storyboard? I know I can hide the view in front of it and temporarily move the view to the front, but that's hard to do over and over again. Is there a way to s

How to edit views hidden behind other views in Xcode Storyboard?

Patrick Patrick Is there an easy way in Xcode to edit views that are hidden behind other views in a Storyboard? I know I can hide the view in front of it and temporarily move the view to the front, but that's hard to do over and over again. Is there a way to s

How to keep continuous ImageView and hide other views?

were able It's my first time working with a designer. He wanted me to implement this complex screen transition. The current screen does not move. But the new screen comes from the right and then stacks up. The problem is this. An ImageView that is an animation

How to keep continuous ImageView and hide other views?

were able It's my first time working with a designer. He wanted me to implement this complex screen transition. The current screen does not move. But the new screen comes from the right and then stacks up. The problem is this. An ImageView that is an animation

How to bring SKSpriteNode to the front?

Toyori How to bring SKSpriteNode in front of all other nodes? With UIView, I can use BringSubviewToFront to bring the uiview in front of other views. fog You can't "put it on top", but you can change zPositionit. zPositionThe higher the value of the node , the

How to bring UICollectionViewCell to the front?

Philip Mueller I recently discovered the Favorites View and my life is much simpler now, but there is one problem. I have some cells in the view (obviously), but the stuff inside can be squeezed. The animation I'm using expands on the outside of the cell's fra

How to bring UICollectionViewCell to the front?

Philip Mueller I've recently discovered the Favorites View and my life is much simpler now, but I'm running into a problem. I (obviously) have some cells in the view, but the stuff inside can be pinched. The animation I'm using expands on the outside of the ce

How to bring UICollectionViewCell to the front?

Philip Mueller I've recently discovered the Favorites View and my life is much simpler now, but I'm running into a problem. I (obviously) have some cells in the view, but the stuff inside can be pinched. The animation I'm using expands on the outside of the ce

How to bring gridlines to the front?

interval 1 How to bring gridlines to the front or back of bars in d3 graphics. Which parameter is responsible for the same job? Sample working violin The code for the scale is:- var yAxisGrid = yAxis.ticks(numberOfTicks) .tickSize(w, 0) .tickFormat("") .orien