Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to align LinearLayout at the center of its parent?
    text
    copied!<p>I've looked through numerous similar questions here at SO, but nothing helps. I have a hierarchy of different nested layouts, all have <code>android:layout_width="fill_parent"</code>, and the inner-most layout has <code>android:layout_width="wrap_content</code> - I need to align it at the center (horizontally). How do I do that?</p> <p><strong>Update:</strong>: I've found the cause of the problem - if I put the inner LinearLayout into RelativeLayout with <code>android:layout_width="fill_parent"</code>, it still wraps it's content. The TableRow, however, is really filling the screen.</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" &gt; &lt;FrameLayout android:layout_width="fill_parent" android:layout_height="wrap_content" &gt; &lt;TableLayout android:layout_width="fill_parent" android:layout_height="wrap_content" &gt; &lt;TableRow &gt; &lt;LinearLayout android:orientation="horizontal" android:layout_width="wrap_content" android:layout_height="wrap_content"&gt; &lt;TextView android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="1" android:textAppearance="?android:attr/textAppearanceLarge" /&gt; &lt;TextView android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="2" android:textAppearance="?android:attr/textAppearanceLarge" /&gt; &lt;/LinearLayout&gt; &lt;/TableRow&gt; &lt;/TableLayout&gt; &lt;/FrameLayout&gt; &lt;/LinearLayout&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload