I am using spinner in an activity with Theme dialog.
I can’t get the spinners to fill parent width – those are always in the length of the text only – no matter what i do. this ismy layout definition.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="match_parent" android:layout_width="match_parent" android:orientation="vertical">
<LinearLayout android:id="@+id/weight_units"
android:layout_width="match_parent" android:gravity="top|center_vertical|center_horizontal"
android:orientation="horizontal" android:layout_marginBottom="3dip" android:layout_marginTop="3dip" android:layout_height="wrap_content">
<TextView android:layout_marginRight="3dip" android:id="@+id/spinner_lbl"
android:text="@string/weight_units"
android:layout_marginLeft="3dip" android:layout_height="wrap_content"
android:layout_width="match_parent" android:layout_gravity="center_vertical|center_horizontal" android:layout_weight="1" ></TextView>
<Spinner android:id="@+id/weight_spinner" android:layout_height="wrap_content" android:layout_weight="1" android:layout_width="match_parent"></Spinner>
</LinearLayout>
<LinearLayout android:orientation="vertical"
android:paddingTop="2dip" android:paddingBottom="2dip" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1">
<TextView android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_marginTop="10dip"
android:text="@string/calc_formula_prompt" />
<Spinner android:id="@+id/calc_spinner" android:layout_height="wrap_content" android:prompt="@string/calc_formula_prompt" android:layout_width="fill_parent"/>
</LinearLayout>
To be clear – i do want the activity to be opened as dialog , and grab most of the screen – but when i landscape – spinner is not stretched to the full parent width.
Thanks in advance
The problem was in the fact that this view was inflated and used as one of the vies in ViewFlipper.
The code which was missing and caused this annoying behaviur was the addition of the flipper to its parent layout with the correct LayoutParams.
I apologize for incomplete question – i had no idea it could be related to the way flipper was added to its parent.