Android view to be centered dynamically in an activity
<p>How can one center align a view on a mobile screen in a complex activity programmatically without knowing the actual layout structure?</p>

<p>Lets say I have an activity layout like this...</p>

<pre><code>&lt;CUSTOMFRAMELAYOUT&gt; //referring to a class extending FRAMELAYOUT
  &lt; LINEARLAYOUT-1&gt;
    &lt;FRAMELAYOUT-1&gt;
        &lt;LINEARLAYOUT-2&gt;
            &lt;TEXTVIEW-1/&gt;
        &lt;/LINEARLAYOUT-2&gt;
    &lt;/FRAMELAYOUT-1&gt;
    &lt;FRAMELAYOUT-2&gt;
    &lt;/FRAMELAYOUT-2&gt;
  &lt;/LINEARLAYOUT-1&gt;
&lt;/CUSTOMFRAMELAYOUT&gt;
</code></pre>

<p>Now without knowing how the layout is defined, I want to remove 'TEXTVIEW-1' from its existing position and want to center it to the root layout</p>

<p>... in this case, the root layout is &lt; CUSTOMFRAMELAYOUT></p>
