views:

269

answers:

1

dear friends,

i have created following layout.

<TableLayout android:layout_width="fill_parent"
        android:layout_height="wrap_content" 
        android:orientation="horizontal"
        >
        <TableRow>


<TextView android:layout_width="fill_parent"
        android:layout_height="wrap_content" android:text="Post As" />


<Spinner 
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:id="@+id/ddlPostAs"
        />
        </TableRow>
        <TableRow>
<TextView android:layout_width="fill_parent"
        android:layout_height="wrap_content" android:text="Expires In" />

<Spinner 
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:id="@+id/ddlExpiryOn"

        />
</TableRow>
</TableLayout>

in which android spinner changes its width according to the data. i want to stop it.

can any one guide me how to achieve this?

any help would be appriciated.

+1  A: 

by fixing the width according to the width of screen.

  DisplayMetrics d = new DisplayMetrics(); 
  getWindow().getWindowManager().getDefaultDisplay().getMetrics(d); 
 int wdt=  dm.widthPixels;
  ddlpostas.getLayoutParams().width=wdt -120;
  ddlexpiryon.getLayoutParams().width=wdt -120;
UMMA