I made an application in which a user can fill in some information in some fields. This works. But when I want to change the lay-out, I have a problem.
I want to have the fields that the user should fill in, in a colored block (background3). So, I put the code in my XML-file in a linear lay-out, but when I do this, all the fields that the user should fill in dissappear. Does anyone know what I did wrong or how I can correct this?
This is the code of my XML-file:
<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/LinearLayout01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/background"
android:orientation="vertical"
android:padding="30dip">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_weight="1"
android:layout_height="0dp"
android:orientation="vertical"
>
<include layout="@layout/header"/>
</LinearLayout>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="6"
android:background="@color/background3"
android:orientation="vertical" >
<TextView
android:id="@+id/button1_label"
android:layout_height="fill_parent"
android:layout_width="wrap_content"
android:text="Voer hieronder je rooster in:"
android:textSize="24.5sp"
android:layout_gravity="center"
android:layout_marginBottom="25dip" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Dag:"
android:layout_gravity="center"
android:textSize="14.5sp" />
<Spinner
android:id="@+id/dag_spinner"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Uur:"
android:layout_gravity="center"
android:textSize="14.5sp" />
<EditText
android:id="@+id/uur"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Vak:"
android:layout_gravity="center"
android:textSize="14.5sp" />
<EditText
android:id="@+id/vak"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Docent:"
android:layout_gravity="center"
android:textSize="14.5sp" />
<EditText
android:id="@+id/docent"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Lokaal:"
android:layout_gravity="center"
android:textSize="14.5sp" />
<EditText
android:id="@+id/lokaal"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<LinearLayout
android:id="@+id/LinearLayout02"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="20sp">
<Button
android:text="Gegevens opslaan"
android:id="@+id/Button01add"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20sp"
android:layout_marginLeft="20sp">
</Button>
<Button
android:text="Terug"
android:id="@+id/Button01home"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20sp"
android:layout_marginLeft="20sp">
</Button>
</LinearLayout>
</LinearLayout>
</LinearLayout>
Your layout’s height is
0dp, usewrap_contentinstead. So change to this:And you don’t have to declare the android namespace in every layout (the
xmlns:android="http://schemas.android.com/apk/res/android"line)And in your
there is a 25dp bottom margin, try to reduce that.
EDIT:
AND your
layout_heightis set tofill_parent, set it towrap_content