Someonation
Someonation

Reputation: 175

make an object in xml that would have the width and height of half of the screen

For the xml line: android:layout_width="fill_parent", is there a const value like fill_parent/2? I want my object to fill only half of the screen and not all of it.

Upvotes: 0

Views: 631

Answers (2)

Khawar
Khawar

Reputation: 5227

You can use "weight" of the linear layout for this purpose. e.g. if you want to divide available space between two control:

<LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
        <EditText 
            android:layout_height="wrap_content"
            android:layout_width="0dp"
            android:layout_weight="1.0"/>
        <EditText 
            android:layout_height="wrap_content"
            android:layout_width="0dp"
            android:layout_weight="1.0"/>
</LinearLayout>

Upvotes: 2

Shailendra Singh Rajawat
Shailendra Singh Rajawat

Reputation: 8242

for proportionate dimension use Layout_weight method for LinearLayout . for your case

<Linearlayout weight_sum=2>
  <yourView layout_weight=1 />
</Linearlayout>

//sudo syntax

Upvotes: 1

Related Questions