Reputation: 155
How to align spinner and a button in one row using linear layout? Here's the code:
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:orientation="vertical"
android:paddingTop="10dp">
<Spinner
android:id="@+id/spinner_delay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:prompt="@string/time_delay"/>
<Button
android:id="@+id/button_send"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Send SMS"
android:layout_marginTop="5dp"
android:layout_marginLeft="230dp"
android:layout_marginRight="5dp"/>
</LinearLayout>
Upvotes: 1
Views: 2066
Reputation: 22493
try this
<LinearLayout
android:orientation="horizontal" ///set orientation like this
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:paddingTop="10dp">
<Spinner
android:id="@+id/spinner_delay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:prompt="@string/time_delay"/>
<Button
android:id="@+id/button_send"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Send SMS"
android:layout_marginTop="5dp"
android:layout_marginLeft="230dp"
android:layout_marginRight="5dp"/>
</LinearLayout>
Upvotes: 0
Reputation: 29121
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:paddingTop="10dp">
<Spinner
android:id="@+id/spinner_delay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:prompt="@string/time_delay"/>
<Button
android:id="@+id/button_send"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Send SMS"
android:layout_marginTop="5dp"
android:layout_marginLeft="230dp"
android:layout_marginRight="5dp"/>
</LinearLayout>
change orientation to horizontal? or don't mention anything, default is horizontal.
Upvotes: 2