I have couple of TableRows, each with a TextView and an EditText inside. But the EditText doesn't fit the table row, even though I've set its width to match_parent. The EditText ends outside the TableRow. I want it to fit the TableRow width.
Here's an image of what I mean:
How can I make it so the EditTexts end here, where it's red?:
Here's my xml:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="32dp"
tools:context=".activity.ConfigScreenActivity">
<LinearLayout
android:id="#+id/linearLayout2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<TableLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:stretchColumns="*">
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/novo_usuario_TextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="#string/novo_usuario_texto"
android:textSize="20sp" />
<EditText
android:id="#+id/novo_usuario_EditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_margin="5dp"
android:ems="10"
android:hint="Novo Usuário"
android:inputType="textPersonName"
android:textColorHint="#color/light_gray"
android:textSize="20sp"
tools:ignore="TextContrastCheck" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/nova_senha_TextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="#string/nova_senha_texto"
android:textSize="20sp" />
<EditText
android:id="#+id/nova_senha_EditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_margin="5dp"
android:ems="10"
android:hint="Nova Senha"
android:inputType="textPassword"
android:textColorHint="#color/light_gray"
android:textSize="20sp"
tools:ignore="SpeakableTextPresentCheck,DuplicateSpeakableTextCheck,TextContrastCheck" />
</TableRow>
</TableLayout>
<TableLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="100dp">
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/confirmar_senha_TextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:singleLine="false"
android:text="#string/confirmar_senha_texto"
android:textSize="20sp" />
<EditText
android:id="#+id/confirmar_senha_EditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_margin="5dp"
android:ems="10"
android:hint="Nova Senha"
android:inputType="textPersonName"
android:textColorHint="#color/light_gray"
android:textSize="20sp" />
</TableRow>
</TableLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="100dp">
<Button
android:id="#+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="20dp"
android:layout_weight="1"
android:text="#string/confirmar_button" />
<Button
android:id="#+id/cancelar_Button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="changeToMainScreen"
android:layout_marginLeft="20dp"
android:layout_weight="1"
android:text="#string/cancelar_button" />
</LinearLayout>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
You can solve this issue by assigning weight to your EditTexts
Try that
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/linearLayout2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="32dp"
android:orientation="vertical"
tools:context=".activity.ConfigScreenActivity">
<TableLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:stretchColumns="*">
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/novo_usuario_TextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="#string/novo_usuario_texto"
android:textSize="20sp" />
<EditText
android:id="#+id/novo_usuario_EditText"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_margin="5dp"
android:layout_weight="1"
android:ems="10"
android:hint="Novo Usuário"
android:inputType="textPersonName"
android:textColorHint="#color/light_gray"
android:textSize="20sp"
tools:ignore="TextContrastCheck" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/nova_senha_TextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="#string/nova_senha_texto"
android:textSize="20sp" />
<EditText
android:id="#+id/nova_senha_EditText"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_margin="5dp"
android:layout_weight="1"
android:ems="10"
android:hint="Nova Senha"
android:inputType="textPassword"
android:textColorHint="#color/light_gray"
android:textSize="20sp"
tools:ignore="SpeakableTextPresentCheck,DuplicateSpeakableTextCheck,TextContrastCheck" />
</TableRow>
</TableLayout>
<TableLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="100dp">
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/confirmar_senha_TextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:singleLine="false"
android:text="#string/confirmar_senha_texto"
android:textSize="20sp" />
<EditText
android:id="#+id/confirmar_senha_EditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_margin="5dp"
android:ems="10"
android:hint="Nova Senha"
android:inputType="textPersonName"
android:textColorHint="#color/light_gray"
android:textSize="20sp" />
</TableRow>
</TableLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="100dp">
<Button
android:id="#+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="20dp"
android:layout_weight="1"
android:text="#string/confirmar_button" />
<Button
android:id="#+id/cancelar_Button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_weight="1"
android:onClick="changeToMainScreen"
android:text="#string/cancelar_button" />
</LinearLayout>
</LinearLayout>
Related
I have a text area like this
When i try to write in the last section, at the bottom, the keyboard covers all of this.
EDIT: This is my layout. The problem is in the linearlayout with id: layout_notas
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/activity_crear_entrenamiento"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include
android:id="#+id/tool_bar"
layout="#layout/toolbar"></include>
<LinearLayout
android:id="#+id/layout_ejercicios"
android:layout_width="match_parent"
android:layout_height="300dp"
android:layout_below="#+id/layout_info"
android:layout_alignParentStart="true">
<TextView
android:text="Ejercicios"
android:textStyle="bold"
android:textSize="30dp"
android:layout_width="match_parent"
android:layout_height="50dp"
android:id="#+id/ejercicios"
android:background="#color/colorPrimary"
android:layout_marginTop="0dp"
android:layout_below="#+id/tool_bar"
android:layout_alignParentStart="true" />
</LinearLayout>
<LinearLayout
android:id="#+id/layout_notas"
android:layout_below="#+id/layout_ejercicios"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentStart="true"
android:orientation="vertical">
<TextView
android:text="Notas"
android:textSize="30dp"
android:textStyle="bold"
android:layout_width="match_parent"
android:layout_height="50dp"
android:id="#+id/notas"
android:background="#color/colorPrimary"
android:layout_marginTop="0dp"
android:layout_below="#+id/tool_bar"
android:layout_alignParentStart="true" />
<EditText
android:id="#+id/textArea_information"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#null"
android:gravity="top|left"
android:inputType="textMultiLine"
android:overScrollMode="always"
android:scrollbarStyle="insideInset"
android:scrollbars="vertical"
android:lines="6"
android:textAppearance="?android:attr/textAppearanceMedium"
android:scrollHorizontally="false" />
</LinearLayout>
<LinearLayout
android:id="#+id/layout_info"
android:layout_width="wrap_content"
android:layout_height="65dp"
android:orientation="horizontal"
android:layout_below="#+id/tool_bar"
android:layout_alignParentStart="true">
<TableLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TableRow>
<TextView
android:text="Hora inicio:"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/tvHoraInicio"
android:textSize="25dp"
android:layout_weight="1" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="time"
android:ems="3"
android:maxLength="5"
android:textSize="25dp"
android:id="#+id/etHoraInicio"
android:layout_weight="1"
android:layout_toRightOf="#+id/tvHoraInicio"/>
<TextView
android:text="Ubicacion:"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/tvUbicacion"
android:textSize="25dp"
android:paddingLeft="50dp"
android:layout_weight="1" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="text"
android:ems="7"
android:textSize="25dp"
android:maxLength="20"
android:id="#+id/etUbicacion"
android:layout_weight="1"
android:layout_toRightOf="#+id/tvUbicacion"/>
</TableRow>
</TableLayout>
</LinearLayout>
</RelativeLayout>
How can i solve it?
I have a LinearLayout with like a contact form for the user to edit his profile. However, the size of the editText just doesn't change no matter what size I give to the layout_weight. Tyvm for any help!
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/first_grey"
android:orientation="vertical"
tools:ignore="ContentDescription">
<include
android:id="#+id/tool_bar"
layout="#layout/toolbar_all_activities" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="none"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:id="#+id/viewUploadPicture"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="25"
android:layout_marginTop="20dp"
android:clickable="true"
android:orientation="horizontal">
<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/imgUserProfile"
android:layout_width="0dp"
android:layout_height="90dp"
android:layout_gravity="center_horizontal"
android:layout_weight="0.5"
android:src="#drawable/skate_boarder" />
<TextView
android:layout_width="0dp"
android:layout_height="80dp"
android:layout_marginEnd="15dp"
android:layout_marginRight="15dp"
android:layout_weight="0.5"
android:gravity="center_vertical|start"
android:text="#string/user.edit.upload_photo"
android:textColor="#color/fourth_grey"
android:textSize="18sp" />
</LinearLayout>
<TextView
style="#style/editProfileTextView"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="40"
android:text="#string/user.first_name" />
<EditText
android:id="#+id/txtEditProfileFirstName"
style="#style/editTextRoundGrey"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="50" />
<TextView
style="#style/editProfileTextView"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="40"
android:text="#string/user.last_name" />
<EditText android:id="#+id/txtEditProfileLastName"
style="#style/editTextRoundGrey"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="50" />
<TextView
style="#style/editProfileTextView"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="40"
android:text="#string/user.edit.favourite_hobby" />
<EditText
android:id="#+id/txtEditProfileFavouriteHobby"
style="#style/editTextRoundGrey"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="50" />
<TextView
style="#style/editProfileTextView"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="40"
android:text="#string/user.edit.birthday_date" />
<LinearLayout
android:id="#+id/birthdayLayout"
android:layout_width="300dp"
android:layout_height="0dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginTop="10dp"
android:layout_weight="50"
android:orientation="horizontal">
<EditText
android:id="#+id/txtDayBirthdayDate"
style="#style/editTextNumberRoundGrey"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.2" />
<EditText
android:id="#+id/txtMonthBirthdayDate"
style="#style/editTextNumberRoundGrey"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:layout_marginStart="10dp"
android:layout_weight="0.2" />
<EditText
android:id="#+id/txtYearBirthdayDate"
style="#style/editTextNumberRoundGrey"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:layout_marginStart="10dp"
android:layout_weight="0.5" />
</LinearLayout>
<TextView
style="#style/editProfileTextView"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="40"
android:text="#string/user.edit.bio" />
<EditText
style="#style/editTextRoundGreyBigger"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="120" />
<TextView
style="#style/editProfileTextView"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="40"
android:text="#string/user.edit.city" />
<EditText
android:id="#+id/txtEditProfileCity"
style="#style/editTextRoundGrey"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="50" />
<TextView
style="#style/editProfileTextView"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="40"
android:text="#string/user.edit.languages" />
<EditText
android:id="#+id/txtEditProfileLanguages"
style="#style/editTextRoundGrey"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="50" />
<TextView
style="#style/editProfileTextView"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="40"
android:text="#string/user.edit.password" />
<EditText
android:id="#+id/txtEditProfilePass"
style="#style/editTextRoundGrey"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="50" />
<Button
android:id="#+id/btnSubmitChangedData"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginTop="15dp"
android:layout_weight="100"
android:padding="10dp"
android:background="#color/red"
android:text="#string/user.edit.submit" />
</LinearLayout>
</ScrollView>
</LinearLayout>
you can't use layout_weight in ScrollView because it depend on the height of the child layout and layout_weight too depend on the height of the outside layout and that's contradiction, so you can use custom layout_height to every child .
I know the answer is late but i hope it help someone else .
The android:layout_weight attribute is used in conjunction with the android:weightSum attribute. Your children layout_weights must sum to the weightSum of their parent layout.
You use layout_weight many times in your xml code without declaring a weightSum. Without android:weightSum, android:layout_weights will have no effect. For instance, if you want two views within a parent LinearLayout to span evenly, you can do something like this:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="100">
<EditText
android:id="#+id/my_edit_text"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="50"
android:hint="type something">
<Button
android:id="#+id/my_button"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="50"
android:text="a button">
</LinearLayout>
Note that your child views' layout_heights will need to be set to "0dp" for vertical LinearLayout orientation. For a horizontal orientation, you'd set the child views' layout_widths to "0dp".
For another example, see the accepted answer at https://stackoverflow.com/a/7452788/4138919
I also notice that you mix floating point values with non-floating point values for layout_weights. Consider sticking to one or the other for readability purposes.
For changing Edittext height you should also prefer to use attributes like maxHeight, minHeight, maxLines, inputTypes, and textAppreance attributes,
This below example might help you :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:ignore="ContentDescription">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="none"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_marginTop="20dp"
android:paddingLeft="5dip"
android:paddingRight="5dip"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="18sp"
android:text="FirstName" />
<!-- Person Name EditText-->
<EditText
android:id="#+id/txtEditProfileFirstName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxHeight="40dip"
android:inputType="textPersonName"
android:maxLines="1"
android:maxLength="25"
android:textAppearance="?android:attr/textAppearanceMedium"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="18sp"
android:text="LastName" />
<EditText android:id="#+id/txtEditProfileLastName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxHeight="40dip"
android:inputType="textPersonName"
android:maxLines="1"
android:maxLength="25"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="18sp"
android:text="Hobby" />
<EditText
android:id="#+id/txtEditProfileFavouriteHobby"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxHeight="40dip"
android:inputType="text"
android:maxLines="2"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="18sp"
android:text="Birthday Date" />
<LinearLayout
android:id="#+id/birthdayLayout"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginTop="10dp"
android:weightSum="1"
android:orientation="horizontal">
`enter code here` <EditText
android:id="#+id/txtDayBirthdayDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.3"
android:inputType="number"
android:gravity="center"
android:layout_gravity="center"
android:maxLength="2"
/>
<EditText
android:id="#+id/txtMonthBirthdayDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginStart="10dp"
android:layout_weight="0.3"
android:gravity="center"
android:layout_gravity="center"
android:inputType="number"
android:maxLength="2"
/>
<EditText
android:id="#+id/txtYearBirthdayDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginStart="10dp"
android:layout_weight="0.4"
android:inputType="number"
android:gravity="center"
android:layout_gravity="center"
android:maxLength="4"
/>
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="18sp"
android:text="Bio" />
<!--MultiLine EdiText-->
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textMultiLine"
android:minHeight="80dp"
android:maxLines="4"
android:isScrollContainer="true"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="18sp"
android:text="City"
/>
<EditText
android:id="#+id/txtEditProfileCity"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxHeight="40dip"
android:inputType="textPostalAddress"
android:maxLines="1"
android:maxLength="25"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="18sp"
android:text="Languages" />
<EditText
android:id="#+id/txtEditProfileLanguages"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxHeight="40dip"
android:inputType="text"
android:maxLines="1"
android:maxLength="25"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="18sp"
android:text="password" />
<!--Password EditText-->
<EditText
android:id="#+id/txtEditProfilePass"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxHeight="40dip"
android:inputType="textPassword"
android:maxLines="1"
android:maxLength="25"
android:textAppearance="?android:attr/textAppearanceMedium"/>
<Button
android:id="#+id/btnSubmitChangedData"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginTop="15dp"
android:layout_weight="1"
android:padding="10dp"
android:background="#color/red"
android:text="Submit" />
</LinearLayout>
</ScrollView>
</LinearLayout>
I am new to Android and working on a App and stuck here on ScrollView. I have tried width and height "match parent" but still not working. I am posting my code. I have wasted more than an hour on this. Thanks in advance.
Here is my XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="1"
android:orientation="vertical">
<LinearLayout
android:id="#+id/linear_header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.02"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="20dp"
android:text="Marketing"
android:textColor="#color/black"
android:textSize="25dp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:id="#+id/linear_register"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/linear_header"
android:layout_weight="0.02"
android:background="#color/light_blue"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="15dp"
android:text="Register Here"
android:textColor="#color/white"
android:textSize="22dp"
android:textStyle="bold" />
</LinearLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/linear_register"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="20dp"
android:layout_weight="0.04"
android:orientation="vertical">
<EditText
android:id="#+id/edit_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Name*"
android:inputType="text" />
<EditText
android:id="#+id/edit_email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:hint="Email*"
android:inputType="text" />
<EditText
android:id="#+id/edit_pswd"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:hint="Password*"
android:inputType="text" />
<EditText
android:id="#+id/edit_cnfrm_pswd"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:hint="Confirm Password*"
android:inputType="text" />
<Button
android:id="#+id/btn_register"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="50dp"
android:layout_marginRight="50dp"
android:layout_marginTop="20dp"
android:background="#drawable/button_bg"
android:padding="15dp"
android:text="Register"
android:textStyle="bold" />
<TextView
android:id="#+id/txt_forgot_pswd"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:text="Forgot/Reset Password"
android:textColor="#color/light_blue" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:weightSum="1"
android:layout_marginBottom="10dp"
android:orientation="horizontal">
<Button
android:id="#+id/btn_google"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="GOOGLE"
android:textColor="#color/white"
android:textStyle="bold"
android:textSize="15sp"
android:layout_marginRight="5dp"
android:background="#color/red"
android:layout_weight="0.5"/>
<Button
android:id="#+id/btn_facebook"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="FACEBOOK"
android:textColor="#color/white"
android:background="#color/fb_blue"
android:layout_marginLeft="5dp"
android:textStyle="bold"
android:textSize="15sp"
android:layout_weight="0.5"/>
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
set lay out weight to scroll view like
<ScrollView
android:layout_weight="0.96"
android:layout_width="match_parent"
android:layout_height="wrap_content">
I have my xml file. It is a RelativeLayout with a ScrollView and inside the ScrollView I have LinearLayout and many more. The problem is that I can't reach the end of the view, as you can see it end with a "Sign Up" button... But my view is cut by the scroll and I can just see the middle of the button, the other middle is off screen.
So, any suggestions for how can I fix this? How can I work with the ScrollView so it wraps all of my content...
Check it:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/bg_signup"
android:orientation="vertical"
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=".SignUp">
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="25dp"
android:background="#xml/signup_round">
<LinearLayout
android:layout_width="260dp"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#xml/border_lines"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/new_signup" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="50dp"
android:text="#string/signup"
android:textColor="#color/colorRB"
android:textSize="26sp"
android:textStyle="bold" />
</LinearLayout>
<EditText
android:id="#+id/first_name_EditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginBottom="10dp"
android:layout_marginTop="-25dp"
android:hint="#string/first_name"
android:textColor="#color/colorRB" />
<EditText
android:id="#+id/last_name_EditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginBottom="10dp"
android:hint="#string/last_name"
android:textColor="#color/colorRB" />
<EditText
android:id="#+id/email_EditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginBottom="10dp"
android:hint="#string/email"
android:inputType="textEmailAddress"
android:textColor="#color/colorRB" />
<EditText
android:id="#+id/email_confirmation_EditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginBottom="10dp"
android:hint="#string/email_confirmation"
android:inputType="textEmailAddress"
android:textColor="#color/colorRB" />
<EditText
android:id="#+id/password_EditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginBottom="10dp"
android:hint="#string/password"
android:inputType="textPassword"
android:textColor="#color/colorRB" />
<EditText
android:id="#+id/password_confirmation_EditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginBottom="10dp"
android:hint="#string/password_confirmation"
android:inputType="textPassword"
android:textColor="#color/colorRB" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#xml/border_lines"
android:text="#string/sex"
android:textColor="#color/colorRB"
android:textSize="26sp"
android:textStyle="bold" />
<Spinner
android:id="#+id/sex_spinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="-25dp"
android:entries="#array/sex_array" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#xml/border_lines"
android:text="#string/brithday"
android:textColor="#color/colorRB"
android:textSize="26sp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="-35dp"
android:orientation="horizontal">
<Button
android:id="#+id/birthdayBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:background="#color/fbutton_color_transparent"
android:onClick="showDatePickerDialog"
android:text="#string/birthdayBtn"
android:textAllCaps="false"
android:textColor="#color/colorRB" />
<Space
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" />
<TextView
android:id="#+id/dateSelectedTv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:text="--/--/--"
android:textColor="#color/colorRB"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:paddingBottom="5dp"
android:text="#string/terms_conditions"
android:textColor="#color/colorRB"
android:textStyle="bold" />
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0" />
</LinearLayout>
<Button
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="5dp"
android:background="#xml/button_round"
android:onClick=""
android:text="#string/signup"
android:textColor="#color/white"
android:textStyle="bold" />
</LinearLayout>
</RelativeLayout>
</ScrollView>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick=""
android:src="#drawable/close_signup" />
</RelativeLayout>
I'm a beginner in android. I'm creating a example phonebook using eclipse. i have few edit texts and a set off buttons in my layout.but when I run the project I can't see the buttons in the bottom of the layout, so I enclosed my main linear layout in a Scrollview. but after linear layout has become much bigger in height. i tried to resize it in the xml file but it is not working right after resizing the layout it automatically resizes in to the previous size. here's my code if anyone can help me.little help is highly appreciated.
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="466dp"
android:layout_gravity="center_vertical" >
<LinearLayout
android:id="#+id/LinearLayout2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/back"
android:orientation="vertical"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:scrollbarAlwaysDrawVerticalTrack="false"
android:scrollbarStyle="insideOverlay"
android:scrollbars="vertical"
tools:context="com.nadusha.phonebook.MainActivity" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_marginBottom="10dp"
android:orientation="vertical" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Contact Info"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#FFFFFF" />
</LinearLayout>
<LinearLayout
android:layout_marginBottom="8dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Name"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#FFFFFF" />
</LinearLayout>
<LinearLayout
android:id="#+id/nameTextLayout"
android:orientation="horizontal"
android:layout_marginBottom="15dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<EditText
android:id="#+id/nameTxt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName" />
<requestFocus />
</LinearLayout>
<LinearLayout
android:layout_marginBottom="8dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Mobile"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#FFFFFF"/>
</LinearLayout>
<LinearLayout
android:layout_marginBottom="15dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<EditText
android:id="#+id/mobileNoTxt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="phone" >
</EditText>
</LinearLayout>
<LinearLayout
android:layout_marginBottom="8dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="#+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Home"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#FFFFFF" />
</LinearLayout>
<LinearLayout
android:layout_marginBottom="15dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<EditText
android:id="#+id/homeNoTxt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="phone" />
</LinearLayout>
<LinearLayout
android:layout_marginBottom="8dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="E-Mail "
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#FFFFFF" />
</LinearLayout>
<LinearLayout
android:layout_marginBottom="15dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<EditText
android:id="#+id/emailTxt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textEmailAddress" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<Button
android:id="#+id/saveBtn"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Save"
android:textColor="#FFFFFF"/>
<Button
android:id="#+id/cancelBtn"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Cancel"
android:textColor="#FFFFFF" />
<Button
android:id="#+id/viewBtn"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="ViewContact"
android:textColor="#FFFFFF" />
</Linearlayout>
</LinearLayout>
You need to set ScrollView layoutWeight to 1 and its height to 0. This will ensure that your scrollview will take only remaining space on screen. Here is example of my app:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<ScrollView
android:id="#+id/scrollView2"
android:layout_width="match_parent"
android:layout_height="0dp"
android:clickable="false"
android:fadeScrollbars="false"
android:layout_weight="1">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="5dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="5dp">
<TextView
android:id="#+id/menoLabel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="2"
android:text="#string/emergencySMSMeno"/>
<EditText
android:id="#+id/menoEdit"
style="#style/editText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:inputType="textPersonName"
android:textColor="#000"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="5dp"
android:weightSum="3">
<TextView
android:id="#+id/pohlavieLabel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="2"
android:text="#string/emergencySMSPohlavie"/>
<Spinner
android:id="#+id/spinnerPohlavie"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="5dp">
<TextView
android:id="#+id/vekLabel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="2"
android:text="#string/emergencySMSVek"/>
<EditText
android:id="#+id/vekEdit"
style="#style/editText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:inputType="numberDecimal"
android:textColor="#000"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="5dp">
<TextView
android:id="#+id/vahaLabel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="2"
android:text="#string/emergencySMSVaha"/>
<EditText
android:id="#+id/vahaEdit"
style="#style/editText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:inputType="numberDecimal"
android:textColor="#000"/>
</LinearLayout>
<TextView
android:id="#+id/alergieLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:padding="5dp"
android:text="#string/emergencySMSAlergie"/>
<EditText
android:id="#+id/alergieEdit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text"
android:textColor="#000"/>
<TextView
android:id="#+id/chorobyLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:padding="5dp"
android:text="#string/emergencySMSChoroby"/>
<EditText
android:id="#+id/chorobyEdit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text"
android:textColor="#000"/>
<TextView
android:id="#+id/zraneniaLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:padding="5dp"
android:text="#string/emergencySMSZranenie"/>
<EditText
android:id="#+id/zraneniaEdit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textMultiLine"
android:lines="3"
android:textColor="#000"/>
<TextView
android:id="#+id/polohaLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:padding="5dp"
android:text="#string/emergencySMSAktualnaPoloha"/>
<EditText
android:id="#+id/polohaEdit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text"
android:textColor="#000"/>
</LinearLayout>
</ScrollView>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="5dp">
<Button
android:id="#+id/odoslatButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/send"
android:layout_weight="1"/>
<Button
android:id="#+id/zrusitButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/emergencySMSZrusit"
android:layout_weight="1"/>
</LinearLayout>
</LinearLayout>
It shows scrollView and two buttons bellow it. I am not exactly sure what you want to do but as far as I can see you are doint it wrong. ScrollView can take only one child element but you have set scrollview as your main parent but then you put more child inside it.
Also you are doing another mistake. You dont need to use linear layouts (in most cases) if they have only one child. It is bad for performance.
Change the value of the attribute layout_height to match_parent so that the ScrollView take up the whole screen and hence enable scrolling. The correct code is
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_vertical" >
<LinearLayout
android:id="#+id/LinearLayout2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/back"
android:orientation="vertical"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:scrollbarAlwaysDrawVerticalTrack="false"
android:scrollbarStyle="insideOverlay"
android:scrollbars="vertical"
tools:context="com.nadusha.phonebook.MainActivity" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_marginBottom="10dp"
android:orientation="vertical" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Contact Info"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#FFFFFF" />
</LinearLayout>
<LinearLayout
android:layout_marginBottom="8dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Name"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#FFFFFF" />
</LinearLayout>
<LinearLayout
android:id="#+id/nameTextLayout"
android:orientation="horizontal"
android:layout_marginBottom="15dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<EditText
android:id="#+id/nameTxt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName" />
<requestFocus />
</LinearLayout>
<LinearLayout
android:layout_marginBottom="8dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Mobile"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#FFFFFF"/>
</LinearLayout>
<LinearLayout
android:layout_marginBottom="15dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<EditText
android:id="#+id/mobileNoTxt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="phone" >
</EditText>
</LinearLayout>
<LinearLayout
android:layout_marginBottom="8dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="#+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Home"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#FFFFFF" />
</LinearLayout>
<LinearLayout
android:layout_marginBottom="15dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<EditText
android:id="#+id/homeNoTxt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="phone" />
</LinearLayout>
<LinearLayout
android:layout_marginBottom="8dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="E-Mail "
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#FFFFFF" />
</LinearLayout>
<LinearLayout
android:layout_marginBottom="15dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<EditText
android:id="#+id/emailTxt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textEmailAddress" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<Button
android:id="#+id/saveBtn"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Save"
android:textColor="#FFFFFF"/>
<Button
android:id="#+id/cancelBtn"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Cancel"
android:textColor="#FFFFFF" />
<Button
android:id="#+id/viewBtn"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="ViewContact"
android:textColor="#FFFFFF" />
</Linearlayout>
</LinearLayout>
You could try changing
android:layout_height="466dp"
to
android:layout_height="wrap_content"
or
android:layout_height="match_parent"