How to set the size of layout more efficiently?
<p>I need my view to be placed in the center and it's width is not a <code>match parent</code> or <code>wrap content</code> but a size of particular percentage of a screen the app is running on. To have a more flexible layout I didn't set its size using dimensions, but defined weights for the elements to have a required size of the main one. In order to do so I've inserted two additional <code>LinearLayouts</code> and defined weights for them. I don't think this is the best solution to increase <code>Views</code> amount within the XML. Can you guys let me know the more efficient way of doing that?</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="match_parent"
                  android:layout_height="match_parent"
                  android:background="@drawable/right_back"
                  android:orientation="horizontal"
                  android:gravity="center"&gt;

&lt;!-- The first one I think which is redundant --&gt;
        &lt;LinearLayout
            android:layout_weight="25"
            android:layout_width="0dip"
            android:layout_height="wrap_content"/&gt;

&lt;!-- Main view I need to be of a required size on each screen size --&gt;
        &lt;LinearLayout
            android:layout_width="0dip"
            android:layout_height="wrap_content"
            android:background="@drawable/layout_round_corners"
            android:orientation="vertical"
            android:layout_weight="50"
            android:padding="20dip"&gt;

            &lt;TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="@string/welcome_text"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:textColor="@color/text_color"
                android:layout_gravity="center_horizontal"/&gt;

            &lt;EditText
                android:id="@+id/edt_firsttimeactivity_first_field"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:hint="@string/password"
                android:password="true"
                android:singleLine="true"/&gt;

            &lt;EditText
                android:id="@+id/edt_firsttimeactivity_second_field"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:hint="@string/repeat_new_password_again"
                android:password="true"
                android:singleLine="true"/&gt;

            &lt;Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal"
                android:onClick="onButtonClick"
                android:text="@string/create_account_for_me"/&gt;
        &lt;/LinearLayout&gt;

&lt;!-- The second one I think which is redundant --&gt;
        &lt;LinearLayout
            android:layout_weight="25"
            android:layout_width="0dip"
            android:layout_height="wrap_content"&gt;&lt;/LinearLayout&gt;


    &lt;/LinearLayout&gt;
</code></pre>
