suku suku - 10 months ago 52
Android Question

How to find the layout type of a view?

I want to avoid

on doing
. Is there a way by which I can get the layout type i.e Relative, Linear or Frame?
Then I would like to use a switch case on the result and then do

Answer Source

You can use instanceof operator.

if(view instanceof RelativeLayout) {
    // do something
} else if(view instanceof LinearLayout) {
    // do something
} else if(view instanceof FrameLayout) {
    // do something