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?
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.
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.
<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>
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 ?
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