I want to add two linear layouts after one layouts to an activity programatically each of same width. the problem is i am not able to set the weights of these layouts programatically. I could do this within xml, but I want to do this in program. here is what i want:
first button contains full width of screen but after this two button will share equal width and so on...
obviously, need to do it programmatically.
my layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:background="@drawable/background"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:tools="http://schemas.android.com/tools"
    tools:context=".HomeActivity">
    <ScrollView
        android:id="@+id/scrollView1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <LinearLayout
            android:id="@+id/linearLayout1"
            android:orientation="vertical"
            android:layout_width="match_parent"
            android:layout_height="match_parent">
        </LinearLayout>
    </ScrollView>
</LinearLayout>
code behinds:
Button button = new Button(HomeActivity.this);
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, 564);
                        layoutParams.setMargins(60, 80, 60, 40);
 Drawable drawable = Drawable.createFromStream(getAssets().open("image/GridButton/NovoTel_IGW_lg.png"), null);
button.setBackground(drawable);
button.setLayoutParams(layoutParams);
linearLayout.addView(button);
I got output like this:
Please suggest, which is the best way.


