Can anyone help me how to enable scrolling functionality for linearlayout?
You cannot make a LinearLayout scrollable because it is not a scrollable container. Only scrollable containers such as ScrollView, HorizontalScrollView, ListView, GridView, ExpandableListView can be made scrollable.
Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main. xml. In this above code, we have declare Linear layout as parent and added Vertical Scroll view.
You can make your activity scrollable using ScrollView. Its very simple and effective to use. Just copy code of ScrollView from below and paste it in your layout xml file. You can use this ScrollView with Linear as well as Relative Layout also.
In Android, a ScrollView is a view group that is used to make vertically scrollable views. A scroll view contains a single direct child only. In order to place multiple views in the scroll view, one needs to make a view group(like LinearLayout) as a direct child and then we can define many views inside it.
Use a ScrollView ?
<LinearLayout android:id="@+id/LinearLayout01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<ScrollView android:id="@+id/ScrollView01"
android:layout_width="fill_parent"
android:layout_height="110px">
</ScrollView>
</LinearLayout>
You can put anything inside a scroll view to make something (LinearLayout, RelativeLayout and etc) scrollable. You can follow http://www.androidpeople.com/android-scrollview-example for more details.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With