Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ScrollView in Fragment

I am doing some stuff in Android 3.0 with fragments. In one of the fragments, I need the scroll bar. I tried using a ScrollView, but it does not give me a scroll bar for the fragment.

How do I get a scroll bar for a fragment?

like image 422
Yog Guru Avatar asked Aug 05 '11 09:08

Yog Guru


People also ask

Is ScrollView a Viewgroup?

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.

What is the difference between ScrollView and horizontal ScrollView?

Attributes Of Scroll View: ScrollView and HorizontalScrollView has same attributes, the only difference is scrollView scroll the child items in vertical direction while horizontal scroll view scroll the child items in horizontal direction.


2 Answers

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >

//enclose your code for contents of fragment here. This helped me to add scroll view to the fragment





</ScrollView>
like image 156
jobin philip Avatar answered Sep 23 '22 15:09

jobin philip


I've found an example in the official Android resources: FragmentLayout. The class DetailsFragment contains a ScrollView which contains a TextView.

I tried the example and it's working on 3.0 SDK Emulator. If it doesn't fix your problem, can you give more details of your code ?

like image 43
Niqo Avatar answered Sep 26 '22 15:09

Niqo