views:

2988

answers:

2

I have had a number of problems with ScrollViews. Recently I tried to create a LinearView which content exceeds the screen size so I created the new layout with parent element ScrollView and set its width and height to custom values (the layout has to appear as dialog - not filling the whole screen).

When the element is selected the red border appears to embrace the rectangle of predefined ScrollView LayoutWidth and LayoutHeight which is OK. Then I placed inside the LinearView and set the values LayoutWidth and LayoutHeight to fill_parent.

Then when I started to add the elements into the LinearLayout the border (red lile) wrapped the inserted elements, not the whole parent ScrollView.

So when the content of the LinearLayout (child of ScrollView) exceeded the size of parent ScrollView the scroll didn't appear and the bottom elements are simply invisible.

Anyway.. in that case the XML content was too extensive to post the question here and now I'm having the same problem with the more simple example.

The following part of the layout is intended to be a scrollable EditText (in case the user input exceeds the primary size of the widget). I wanted to set the EditText height to 120px, so I set the parent ScrollView height to 120px and the child EditText to fill_parent. Again in this case the EditText doesn't fill the whole ScrollView area but a single line:

 <ScrollView android:layout_height="120px" android:layout_width="fill_parent">
<EditText android:id="@+id/txtContent" android:layout_height="fill_parent" android:layout_width="fill_parent" android:text="TestContent">
</EditText>
</ScrollView>

Does anyone know how to reshape the content above so the EditText fills the parent control and in case the user's input exceeds the control size the scroll appears?

Thank you!

Edit:

Below are the screenshots of the layout

alt text alt text

+9  A: 

Your EditText should have a height of wrap_content. fill_parent has no meaning in a ScrollView. If you want the EditText to fill your ScrollView when it's content is smaller than the ScrollView, use android:fillViewport="true" on the ScrollView.

Romain Guy
A: 

I am using photostream [1] in my application. I am facing a problem. I have spent hours on that but i am not able to find a solution. I have an xml file.

<com.google.android.photostream.GridLayout
    style="@style/PhotoGrid"
    android:id="@+id/grid_photos"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:paddingLeft="10dip"
    android:paddingTop="15dip"
    android:paddingRight="10dip"
    android:paddingBottom="55dip"
    android:orientation="vertical" />

this works fine. But if gridLayout's contents expand beyond the screen size i cant see them. I tried to change FrameLayout with ScrollView. But in this case the application crashes. Anyone help me out please.

1

Sam
Do not put a question in an answer. Make a new question for this.
Ricket
Question? in an answer? -1 for question inside an answer. Maybe you're new here, but click the new question button at the top if you have a question.
Jack Love