Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

min height fill_parent and height wrap_content in ScrollView? (or just the email app compose layout's code)

Question If I have the following:

<ScrollView android:layout_width="fill_parent" android:layout_height="fill_parent">     <LinearLayout android:layout_width="fill_parent" android:layout_height="?" android:orientation="vertical">         <EditText android:layout_width="fill_parent" android:layout_height="?" android:hint="Subject" android:id="@+id/subject" />         <EditText android:layout_width="fill_parent" android:layout_height="?" android:id="@+id/body" />     </LinearLayout> </ScrollView> 

How can I get the body (second EditText) to fill the rest of the screen, but still have the scrollview kick in when the contents of the body are too long? Like a height="wrap_content" and minHeight="fill_parent"

layout_height="fill_parent" seems to not do anything if you put them in a scrollview

A working example of what I want is the email app compose window

I tried this and the EditText elements act like they are wrap_content and no filling is happening. Just scrolling if you type enough

<ScrollView android:layout_width="fill_parent" android:layout_height="fill_parent">     <LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical">         <EditText android:layout_width="fill_parent" android:layout_height="fill_parent" layout_weight="1" android:hint="Subject" android:id="@+id/subject" />         <EditText android:layout_width="fill_parent" android:layout_height="fill_parent" layout_weight="1" android:id="@+id/body" />     </LinearLayout> </ScrollView> 
like image 733
700 Software Avatar asked Oct 07 '10 13:10

700 Software


People also ask

What is Match_parent and Wrap_content in Android?

fill_parent and match_parent are the same, used when we want the height or width of a view to be as big as its parent view, fill_parent being deprecated. wrap_content is used when we want the view to occupy only as much space as required by it. You may also read : Android UI Layouts.

What does Wrap_content mean in Android?

wrap_content is used to wrap the view according to its actual size. It can be used with layout_height as well as layout_width. If we set layout_height as wrap_content then the height will be the same as the content size and if we set layout_width as wrap_content then the width will be the same as the content size.

What is the difference between wrap content and match parent in android studio?

FillParent/Match parent: Fill parent is the older version, the updated one is the match parent which takes the entire screen. Wrap Content: Wrap content takes the length of the text and wraps its content. Example: “This is a Wrap Text”. The wrap content starts wrapping from “This” and ends at “text”.

What is layout height?

Android layout Width & HeightThis property is used to set the width of the given control. This property has following options:- Wrap_content :- when you set width as wrap_content then it will take the space according to the content. For example. Figure 1.


1 Answers

I ran across a link to the mail app source code in my accepted answer on another question. The answer is simple! Add android:fillViewport="true" to the <ScrollView...> and add android:layout_weight="1.0" to the view you want to take up all the available space. explained in this blogspot

like image 82
700 Software Avatar answered Sep 26 '22 00:09

700 Software