3

Can someone explain me why the scrollview doesnt show his child elements? I have a Alot of textviews inside a linearlayout vertical, that linearlayout is inside the scrollview...

But I dont see any scrollview neither the textviews..

Here is the XML Layout

<RelativeLayout 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" > <TextView android:id="@+id/description" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_above="@+id/scrollViewCheck" android:gravity="center" android:padding="10dip" android:text="Pick which items you want to count" android:textAppearance="?android:attr/textAppearanceMedium" > </TextView> <ScrollView android:id="@id/scrollViewCheck" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_above="@+id/bottomSettings" android:scrollbarFadeDuration="0" > <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center_horizontal" android:orientation="vertical" > <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Test" android:textAppearance="?android:attr/textAppearanceMedium" /> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Test" android:textAppearance="?android:attr/textAppearanceMedium" /> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Test" android:textAppearance="?android:attr/textAppearanceMedium" /> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Test" android:textAppearance="?android:attr/textAppearanceMedium" /> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Test" android:textAppearance="?android:attr/textAppearanceMedium" /> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Test" android:textAppearance="?android:attr/textAppearanceMedium" /> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Test" android:textAppearance="?android:attr/textAppearanceMedium" /> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Test" android:textAppearance="?android:attr/textAppearanceMedium" /> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:text="Test" android:textAppearance="?android:attr/textAppearanceMedium" /> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:text="Test" android:textAppearance="?android:attr/textAppearanceMedium" /> </LinearLayout> </ScrollView> <RelativeLayout android:id="@id/bottomSettings" android:layout_width="fill_parent" android:layout_height="wrap_content" > <Button android:id="@+id/timeButton" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Choose Count Time" /> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_below="@id/timeButton" android:orientation="horizontal" > <Button android:layout_width="0dip" android:layout_height="wrap_content" android:layout_weight="1" android:text="Back" /> <Button android:layout_width="0dip" android:layout_height="wrap_content" android:layout_weight="1" android:text="Start" /> </LinearLayout> </RelativeLayout> </RelativeLayout> 

Thanks in advance ;)

3 Answers 3

2

The problem with the view has something to do with the RelativeLayout at the bottom. This should fix your issue. Replace the RelativeLayout at the bottom with this:

 <LinearLayout android:id="@+id/bottomSettings" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:layout_alignParentBottom="true"> <Button android:id="@+id/timeButton" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Choose Count Time" /> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_below="@id/timeButton" android:orientation="horizontal" > <Button android:layout_width="0dip" android:layout_height="wrap_content" android:layout_weight="1" android:text="Back" /> <Button android:layout_width="0dip" android:layout_height="wrap_content" android:layout_weight="1" android:text="Start" /> </LinearLayout> </LinearLayout> 
Sign up to request clarification or add additional context in comments.

3 Comments

This fixed the whole thing, but dude sometimes I get stuck at many layouts... there are so many glitches. I mean, layouts should be easier to make, there are many minor things that change the whole content. Is there any way to design it quicker and simpler? The adt activity design mode isn't good at all.. Thanks !
@DarkLink The way that I normally do the design is start with something really simple and add elements to it one at a time. That way I know where the issue popped up at.
Yes that is what I was expecting, alot of trial and error, like David Wasser said :) Thanks !
2

You are using a RelativeLayout as your root layout and are missing layout instructions like android:layout_below or android:layout_above.

That is why the elements are overlaying each other and you do not see your ScrollView.

Change your root layout to a LinearLayout with the attribute android:orientation="vertical" and you'll see all your widgets.

Comments

1

I don't think you can define a ScrollView height as "wrap_content". Since the content is far larger than will fit on the screen. Usually you need to define the height of a ScrollView as some fixed value. If you want the ScrollView to take up as much of the screen as possible, while still having your header and footer views, you might try this:

 android:layout_height="1dp" android:layout_weight="1" 

This will basically assign all the remaining space on the screen to the ScrollView. I've not got a machine here to test this, but give it a try and let me know how it works out.

3 Comments

I tested this solution, and it also works ! Thanks ;) By the way can you say something about this: "sometimes I get stuck at many layouts... there are so many glitches. I mean, layouts should be easier to make, there are many minor things that change the whole content. Is there any way to design it quicker and simpler? The adt activity design mode isn't good at all.. Thanks ! "
I don't really have any suggestion for you. I don't use the ADT stuff, I just edit XML and try again. It has taken me a long time to even begin to understand how the different layout parameters interact with each other. Unfortunately, there are many different ways to achieve results and there are complicated dependencies and interactions between different layout parameters. The designers/developers of Android have never felt the need to document in detail all of these dependencies, so you and I have to figure it out by trial and error. Of course, StackOverflow users are a big help :-)
they DEFINITELY are! If there were no members like you I would be very lost figuring out why things do not work, thanks again! I understand thanks for the explanation, lets hope they will publish good documentation covering all the little details :)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.