I have a Linear Layout with 2 buttons of equal weights. So they occupy the whole screen(width wise).
In another Linear Layout below the 1st, i only have 1 button, whose width i want to be same as any 1 of the previous 2 buttons.
Is there a simple way to do, other than using gridview or tableview etc..,
I tried this:
Button one = (Button) findViewById(R.id.one);
Button two = (Button) findViewById(R.id.two);
Button three = (Button) findViewById(R.id.three);
three.setLayoutParams(new LinearLayout.LayoutParams(
one.getLayoutParams()));
Layout:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/first"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:id="@+id/one"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
<Button
android:id="@+id/two"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
</LinearLayout>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/second"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/first"
android:orientation="horizontal" >
<Button
android:id="@+id/three"
android:layout_width="150dp"
android:layout_height="wrap_content" />
</LinearLayout>
But the 3rd Button is invisible now.
Thank You
try this for second row