0

I want a screen to look like this:

![What I want to see]https://i.sstatic.net/E5L4g.png

And I wrote the following code to get something similar:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
 <ScrollView
   android:layout_width="fill_parent"
   android:layout_height="fill_parent"
   android:layout_weight="1"
   android:fillViewport="true">
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
        <EditText 
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:id="@+id/txtSendMail"
            android:layout_gravity="center"
            android:padding="10dip"
            android:text="[email protected]">
        </EditText>
        <EditText 
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:id="@+id/txtSubjectMail"
            android:layout_gravity="center"
            android:padding="10dip"
            android:text="Escriba un asunto"
            >
        </EditText>
        <EditText 
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:id="@+id/txtBodyMail"
            android:layout_gravity="top"
            android:padding="10dip"
            android:text="Escribe el mensaje aquí."
            android:inputType="textMultiLine">
        </EditText>

        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/btnSendMail"
            android:text="Send" >
        </Button>
    </LinearLayout>
</ScrollView>

But when I wrote the EditText that will contain the body of the mail, I put android:inputType="textMultiLine" android:layout_height="fill_parent"

I can't see the button. I'm sure that the EditText that "fills" parent is hiding it, but I don't know what property to set if I want the EditText to be as big as the rest of the Screen...

Thank you!

1 Answer 1

2

I've modified your xml a bit. I think your body edittext should scroll and not the whole layout. So I removed the scrollview. Here is the xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
        <EditText 
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:id="@+id/txtSendMail"
            android:padding="10dip"
            android:text="[email protected]">
        </EditText>
        <EditText 
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:id="@+id/txtSubjectMail"
            android:padding="10dip"
            android:text="Escriba un asunto"
            >
        </EditText>
        <EditText 
            android:layout_width="fill_parent"
            android:layout_height="0dip"
            android:layout_weight="1.0"
            android:id="@+id/txtBodyMail"
            android:padding="10dip"
            android:text="Escribe el mensaje aquí."
            android:inputType="textMultiLine">
        </EditText>

        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/btnSendMail"
            android:layout_gravity="center_horizontal"
            android:text="Send" >
        </Button>
</LinearLayout>

If you want it as earlier, you can use your own xml just notice the body edittext attributes should be

layout_height="0dip"
layout_weight="1.0"

This tells the parent that this view should take the remaining space after all the other child views.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you, that was the solution. But I wanted to scroll the whole screen, so I didn't remove if from my code, but the height and the weight solved my problem :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.