Suppose I have the xml:
<LinearLayout ...>
<LinearLayout a:id=«@+id/inner» .../>
</LinearLayout>
And what I am writing in code:
LinearLayout inner = (LinearLayout) findViewById(R.id.inner);
RelativeLayout.LayoutParams params = ((RelativeLayout.LayoutParams)) inner.getLayoutParams();
This is definitely an error which leads to exception in runtime, because the parent of inner is not RelativeLayout, but LinearLayout, and their layoutparams can not be cast to each other.
Is there any static analyzer or a lint rule to verify that? How do we eliminate that kind of erros?