Problems with appearance in XML Android
I want a screen to look like this:
![What I want to see]http://i.stack.imgur.com/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="mail@gmail.com">
</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>
</LinearL开发者_C百科ayout>
</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!
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="mail@gmail.com">
</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.
精彩评论