How to show a View such that it obscures the View it is placed on top of?

I want to place a View (A) on top of another View (B). However, when I do so using a FrameLayout or a RelativeLayout (such that View A and View B are both set to be in the same position) I can see View B faintly through View A. I want instead for View A to obscure View B totally out of sight. Is this is possible?

Note: ViewSwitcher will not do for my particular need nor will setting the visibility of View B to 'invisible'/'gone' as I need View B to be 'visible' and fixed in place whilst View A is sliding/animating in and out of sight.

Answers


Yes, that is possible. You can set the visibility of the corresponding View to either View.INVISIBLE or View.GONE. Do this in code with setVisibility(int) or use xml.

<View ... android:visibility="gone" />

Did you try declaring (View) B before declaring (View) A?

Can you show me your xml layout, might be able to help.


It is possible by giving View A a background resource, i.e. an opaque drawable or color.


Need Your Help

Custom UIView inside a UIViewController button click to refresh UIViewController

ios objective-c uiview uiviewcontroller

I have a custom UIView which has been loaded into a different UIViewController. I have a button in the custom UIView, which calls a method inside its own class. I want this method to refresh the