getting ClassCastException when traversing all childs in LinearLayout view?
<p>I want traverse in a linear layout heiarchiy to all views, but i am getting exception in last element, in frame layout, and its correct class.</p>

<pre><code>public void traverseRootsViewAndSetLayoutParam(View view,
        double heightRatio, double widthRatio) {
    view.setLayoutParams(new LinearLayout.LayoutParams(
            (int) (((double) widthRatio) * (view.getWidth())),
            (int) (((double) heightRatio) * (view.getHeight()))));
    if (view instanceof LinearLayout || view instanceof FrameLayout) {
        if (view instanceof LinearLayout) {
            System.out.println("&gt;&gt;&gt; LinearLayout Class &gt;&gt;&gt; "
                    + view.getClass());
            int childcount = ((LinearLayout) view).getChildCount();
            for (int i = 0; i &lt; childcount; i++) {
                View childView = ((LinearLayout) view).getChildAt(i);
                traverseRootViewAndSetLayoutParam(childView, heightRatio,
                        widthRatio);
            }
        } else if (view instanceof FrameLayout) {
            System.out.println("&gt;&gt;&gt; FrameLayout Class &gt;&gt;&gt; "
                    + view.getClass());
            // getting error here , even the view is framelayout???
            int childcount = ((FrameLayout) view).getChildCount();
            for (int i = 0; i &lt; childcount; i++) {
                View childView = ((FrameLayout) view).getChildAt(i);
                traverseRootViewAndSetLayoutParam(childView, heightRatio,
                        widthRatio);
            }
        }
    }
}
</code></pre>
