Reputation: 212
i have the following xml file for my mini image editing app:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/RelativeLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.imageeditor.MainActivity$PlaceholderFragment" >
<Spinner
android:id="@+id/Dateispinner1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="16dp"
android:entries="@array/Datei" />
<Spinner
android:id="@+id/Bearbeitenspinner2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/DEspinner4"
android:layout_below="@+id/DEspinner4"
android:entries="@array/Bearbeiten" />
<Spinner
android:id="@+id/Werkzeugespinner3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/Dateispinner1"
android:layout_below="@+id/Dateispinner1"
android:layout_marginTop="17dp"
android:entries="@array/Werkzeuge" />
<Spinner
android:id="@+id/DEspinner4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/Dateispinner1"
android:layout_below="@+id/Dateispinner1"
android:layout_marginTop="102dp"
android:entries="@array/DE" />
</RelativeLayout>
i want these spinners just next to each other and they should look sth like this in the end:
i tried it also with different layouts. but sofar with no success. what am i doing wrong? maybe using spinners is not the best option?? am open to ideas.
thanks!
Upvotes: 0
Views: 1246
Reputation: 876
Given Answer not Justify the Question.
You remove this Line for widgets will work for you no need to change whole xml.
android:layout_alignLeft="@+id/Dateispinner1"
This Property Align spinner left to given @+id/Dataspinner1. So removing this will have no reference .
Better to give data spinner 2 property android:layout_below="@+id/Dateispinner1"
,
Data spinner 3 Property android:layout_below="@+id/Dateispinner2"
and so on.
will work 100 %
Upvotes: 2
Reputation: 1444
you can try like this :
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/RelativeLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:weightSum="4" >
<Spinner
android:id="@+id/Dateispinner1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:entries="@array/Datei" />
<Spinner
android:id="@+id/Bearbeitenspinner2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:entries="@array/Bearbeiten" />
<Spinner
android:id="@+id/Werkzeugespinner3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:entries="@array/Werkzeuge" />
<Spinner
android:id="@+id/DEspinner4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:entries="@array/DE" />
</LinearLayout>
Upvotes: 1
Reputation: 7415
You can use Linear layout with weight
. Change weight as per your requirement.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/RelativeLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="Horizontal"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.imageeditor.MainActivity$PlaceholderFragment" >
<Spinner
android:id="@+id/Dateispinner1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginTop="15dp"
android:entries="@array/Datei" />
<Spinner
android:id="@+id/Bearbeitenspinner2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginTop="15dp"
android:entries="@array/Bearbeiten" />
<Spinner
android:id="@+id/Werkzeugespinner3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginTop="15dp"
android:entries="@array/Werkzeuge" />
<Spinner
android:id="@+id/DEspinner4"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginTop="15dp"
android:entries="@array/DE" />
</LinearLayout>
Upvotes: 1