Dynamic alignment of a toggle button
<p>I have been working with android over past few months, but am still not sure of how to align a button dynamically. I did it using xml but then it becomes strongly typed ... which in my case is not required. So anyone please help me n tell me how to place a toggle button with the help of java code and not with xml.
For example:
If i want to place a toggle button to the extreme bottom right of the screen. Please help am stuck on this.</p>

<p>Here is my xml:</p>

<pre><code>   &lt;?xml version="1.0" encoding="utf-8"?&gt;
    &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:weightSum="1"&gt;
        &lt;RelativeLayout android:id="@+id/relativeLayout1" android:layout_width="match_parent"
        android:layout_height="348dp"&gt;
          &lt;EditText android:layout_width="wrap_content" android:layout_height="wrap_content"  
           android:id="@+id/editText1" android:layout_alignParentTop="true" 
           android:layout_alignParentLeft="true" android:layout_marginLeft="27dp" 
           android:layout_marginTop="55dp" android:layout_alignParentRight="true"&gt;&lt;/EditText&gt;
        &lt;/RelativeLayout&gt;
    &lt;/LinearLayout&gt;
</code></pre>

<p>and java part is here.....</p>

<pre><code>package org.in;

import android.app.Activity;
import android.os.Bundle;
import android.view.Gravity;
import android.view.ViewGroup.LayoutParams;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;

public class AsbdActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);


        RelativeLayout rl=(RelativeLayout)findViewById(R.id.relativeLayout1);

        EditText ed=(EditText)findViewById(R.id.editText1);
        ed.setGravity(Gravity.BOTTOM);

    }
}
</code></pre>

<p>even after setting gravity the editext remains at the place specified in xml.</p>
