layout_weight in float and decimal
<p>I change the width of a view dynamically in my code using:</p>

<pre><code>            final ImageButton ButtonTwo = (ImageButton)findViewById(R.id.callButton);

            LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) ButtonTwo.getLayoutParams();
            params.weight = 1.3f;
            ButtonTwo.setLayoutParams(params);
</code></pre>

<p>The idea is that it matches another view in XML :</p>

<pre><code>&lt;ImageButton
    android:layout_height="match_parent"
    android:layout_width="0dp"
    android:id="@+id/imageButton"
    android:src="@drawable/softkeyboard"
    android:clickable="true"
    android:onClick="softkeyboardButton"
    android:layout_gravity="center_horizontal"
    android:layout_weight="1.3"
    android:background="@drawable/buttonstates"
     /&gt;
</code></pre>

<p>They're not the same width - the first button is wider than the second one. I know that this is because one is float and one is decimal, but how can I make them both the decimal size, or should I just do trial and error on the float value? My params.weight only accepts float values.</p>

<p><strong>EDIT:</strong>
Here's my XML code:</p>

<pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/LinearLayout1"
    android:layout_height="match_parent"
    android:layout_width="match_parent"
    android:orientation="vertical"
    android:paddingBottom="0dp"
    android:paddingLeft="0dp"
    android:paddingRight="0dp"
    android:paddingTop="0dp"
    tools:context=".MainActivity"&gt;

    &lt;ListView
        android:id="@+id/ListView_2"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:layout_weight="1"&gt;
    &lt;/ListView&gt;
&lt;!--Let's set the height of the linearlayout below to 0dp. Apparently it's less work on resources,
as otherwise we would be drawing it twice, because the size is also set dynamically--&gt;
&lt;LinearLayout
    android:id="@+id/LinearLayout2"
        android:layout_width="match_parent"
        android:layout_height="60dp"
        android:orientation="horizontal"
        &gt;
        &lt;!--android:adjustViewBounds="true"--&gt;
    &lt;!-- we want the text to begin in the centre of the edittext view
    that's what gravity does--&gt;

    &lt;EditText
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:id="@+id/editText"
        android:inputType="phone"
        android:gravity="center"
        android:background="#d9d9d9"
        android:layout_weight="4"

        /&gt;


        &lt;ImageButton
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:id="@+id/callButton"
            android:src="@drawable/call"
            android:clickable="true"
            android:onClick="softkeyboardButton"
            android:background="#ffa62b"
            android:layout_weight="2"

            /&gt;
&lt;/LinearLayout&gt;

    &lt;LinearLayout
        android:layout_width="match_parent"
        android:layout_height="60dp"
        android:orientation="horizontal" &gt;

    &lt;CheckBox
        android:layout_height="match_parent"
        android:layout_width="0dp"
        android:background="#ffa500"
        android:text="New CheckBox"
        android:id="@+id/checkBox"
        android:layout_weight="5"
        /&gt;


        &lt;ImageButton
            android:layout_height="match_parent"
            android:layout_width="0dp"
            android:id="@+id/imageButton"
            android:src="@drawable/softkeyboard"
            android:clickable="true"
            android:onClick="softkeyboardButton"
            android:layout_gravity="center_horizontal"
            android:layout_weight="1.3"
            android:background="@drawable/buttonstates"
             /&gt;

        &lt;View android:layout_height="fill_parent"
            android:layout_width="2px"
            android:background="#90909090"/&gt;

        &lt;ImageButton
            android:layout_height="match_parent"
            android:layout_width="0dp"
            android:id="@+id/imageButton2"
            android:src="@drawable/settingsicon"
            android:background="@drawable/buttonstates"
            android:layout_gravity="center_horizontal"
            android:layout_weight="1.3" /&gt;

    &lt;/LinearLayout&gt;

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