Reputation: 145
I'm new to android , and I have a problem with relativeLayout ,All the views inside the relative Lyout are not showing : editTexts and spinners , and I can't see where the error is :(
here is the xml file :
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0.01"
android:orientation="horizontal"
android:padding="10dp" >
<EditText
android:id="@+id/fname"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.0"
android:hint="@string/fname"
android:inputType="text"
android:textSize="12sp"
/>
<EditText
android:id="@+id/lname"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.0"
android:hint="@string/lname"
android:inputType="text"
android:textSize="12sp"
android:layout_toRightOf="@+id/fname"
/>
<Spinner
android:id="@+id/catspin"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:entries="@array/cat"
android:prompt="@string/cat"
android:layout_below="@+id/fname"
/>
<Spinner
android:id="@+id/rolespin"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:entries="@array/role"
android:prompt="@string/role"
android:layout_toRightOf="@+id/catspin"
/>
<EditText
android:id="@+id/oparea"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.0"
android:hint="@string/oparea"
android:inputType="text"
android:textSize="12sp"
android:layout_below="@+id/catspin"
/>
<EditText
android:id="@+id/job"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.0"
android:hint="@string/job"
android:inputType="text"
android:textSize="12sp"
android:layout_below="@+id/oparea"
/>
<EditText
android:id="@+id/phone"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.0"
android:hint="@string/phone"
android:inputType="text"
android:textSize="12sp"
android:layout_below="@+id/job"
/>
<EditText
android:id="@+id/email"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.0"
android:hint="@string/email"
android:inputType="text"
android:textSize="12sp"
android:layout_toRightOf="@+id/phone"
/>
</RelativeLayout>
Upvotes: 0
Views: 1106
Reputation: 467
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="10dp"
xmlns:android="http://schemas.android.com/apk/res/android">
<EditText
android:id="@+id/fname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="@string/fname"
android:inputType="text"
android:textSize="12sp"
/>
<EditText
android:id="@+id/lname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="@string/lname"
android:inputType="text"
android:textSize="12sp"
android:layout_toRightOf="@+id/fname"
/>
<Spinner
android:id="@+id/catspin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:entries="@array/cat"
android:prompt="@string/cat"
android:layout_below="@+id/fname"
/>
<Spinner
android:id="@+id/rolespin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:entries="@array/role"
android:prompt="@string/role"
android:layout_toRightOf="@+id/catspin"
/>
<EditText
android:id="@+id/oparea"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1.0"
android:hint="@string/oparea"
android:inputType="text"
android:textSize="12sp"
android:layout_below="@+id/catspin"
/>
<EditText
android:id="@+id/job"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1.0"
android:hint="@string/job"
android:inputType="text"
android:textSize="12sp"
android:layout_below="@+id/oparea"
/>
<EditText
android:id="@+id/phone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1.0"
android:hint="@string/phone"
android:inputType="text"
android:textSize="12sp"
android:layout_below="@+id/job"
/>
<EditText
android:id="@+id/email"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1.0"
android:hint="@string/email"
android:inputType="text"
android:textSize="12sp"
android:layout_toRightOf="@+id/phone"
/>
</RelativeLayout>
Upvotes: 0
Reputation: 23638
Remove android:layout_weight="0.01" android:orientation="horizontal"
this two properties from your RelativeLayout
and then check.
android:layout_weight
doesn't work in a RelativeLayout
, it's for LinearLayout
. So make your EditTexts and Spinner's android:layout_width="wrap_content"
.
Upvotes: 0
Reputation: 355
Linear layout you can assign orientation but in relative layouts its overlap one another so you need to make id for each and make layout_below in each views
Upvotes: -2
Reputation: 152927
layout_weight
does not work in a RelativeLayout
, it's for LinearLayout
s. So your EditText
s and Spinner
s are all 0dp
wide and thus not visible.
Upvotes: 4