How to Make My Layout Able to Scroll Down

How to make my layout able to scroll down?

Just wrap all that inside a ScrollView:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<!-- Here you put the rest of your current view-->
</ScrollView>

As David Hedlund said, ScrollView can contain just one item... so if you had something like this:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<!-- bla bla bla-->
</LinearLayout>

You must change it to:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<!-- bla bla bla-->
</LinearLayout>
</ScrollView>

How do you make a LinearLayout scrollable?

Wrap the linear layout with a <ScrollView>

See here for an example:

 <?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<!-- Content here -->
</LinearLayout>
</ScrollView>
</LinearLayout>

Note: fill_parent is deprecated and renamed to match_parent in API Level 8
and higher.

How do I make a LinearLayout scrollable?

Place your layout in a ScrollView.

ScrollView - How to scroll down while designing layout in Eclipse?

You can change screen size to custom..
try this..
click on current screen button, and select "Add Custom", then scroll down and select Custom and click "New" in right top corner..
Then write your custom size for screen and click "OK", then again "OK"..
Afterward again click on your current screen button and select your custom size.. Done!
Hope helped!

Be sure that this buttons is selected..
Sample Image

Make LinearLayout scrollable and preserve title bar

I had finally figured out my problem. The reason why Actionbar is missing is because ScrollView was placed outside LinearLayout. To fix this, use another LinearLayout to wrap the ScrollView, as shown below.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
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"
tools:context="com.example.android.MainActivity">

<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin">

<!-- Blah blah blah -->

</LinearLayout>
</ScrollView>
</LinearLayout>

Thanks to everyone, especially @arvicx, for their time! :)

I hope everyone who had this problem find this useful.

Scrolling a scroll view in android studio

Found the solution, though I don't why it worked. I changed the selected device in the editor to a custom one and it just started working. I want to think that my editor was somehow frozen, that's why it wasn't scrolling.

I have never developed an app that exceeds the screen size thus the struggle.

Thank you all for trying to help, your responses are highly appreciated.



Related Topics



Leave a reply



Submit