5

I have a LinearLayout that has a lot of TextViews programatically put in. By a lot, I mean it extends beyond the bottom of my screen. I want to use a ScrollView to allow the user to scroll beyond the screen and see the rest of the TextViews. This is my activity_main.xml currently:

<?xml version="1.0" encoding="utf-8"?> <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" > <LinearLayout android:id="@+id/ll" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="61dp" android:orientation="vertical" > </LinearLayout> </ScrollView> 

Any help will be greatly appreciated! Thanks!

3
  • Great! But what exactly is the problem you are having? Commented Nov 7, 2014 at 5:51
  • use match_parent property for linearlayout height and width first.. and then show ur code so we can knw what have u tried... Commented Nov 7, 2014 at 5:53
  • use match_parent for your ScrollView height. Commented Nov 7, 2014 at 6:15

3 Answers 3

1

Try changing android:layout_width="wrap_content" to android:layout_width="match_parent"

<LinearLayout android:id="@+id/ll" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginBottom="61dp" android:orientation="vertical" > </LinearLayout> </ScrollView> 
Sign up to request clarification or add additional context in comments.

1 Comment

Jep, make the height match_parent
1

Change your code as below !

<?xml version="1.0" encoding="utf-8"?> <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" > <LinearLayout android:id="@+id/ll" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="61dp" android:orientation="vertical" > </LinearLayout> </ScrollView> 

NOTE: To see if it is scrolling or not try placing some views inside linearLayout like buttons otherwise you won't notice the screen scrolling

Comments

1

Also You Can Do Like This.It Works Well.

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/scrollData" android:layout_width="fill_parent" android:layout_height="fill_parent" android:scrollbars="vertical" > <LinearLayout android:id="@+id/linearWhere" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="15dp" android:orientation="vertical" android:padding="5dp"> </LinearLayout> </ScrollView> 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.