What code you have to write the scroll view b4a be coordinated with some text labels This means that if the text is too long scroll set up the same amount ?
2 Answers
Are you referring to the layout not scrolling down since you have lots of labels which are out of view? If so, use this reference.
just simply replace the scrollview layout to your parent layout.
<?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:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
// Write something
</LinearLayout>
</ScrollView>

- 113
- 3
- 14
Start with defining label size (particularly the height). If your label size for example is:
Dim intLabelSize As Int
Dim intScrollHeight As Int
intLabelSize = 50dip
you have to figure out if the labels number is static or dynamical, also how much space there would be between labels. If the number of labels is static (for example 4):
intScrollHeight = ((labelheightdip+spacedip)*(numberoflabels+1.5)) + 5dip
Without 1.5 labels and scroll are not visualized correctly on different size devices, you can play with this index according the results.
intScrollHeight = ((intLabelSize +10dip)*(4+1.5)) + 5dip
However, more common case is to write the code based on dynamic number of the labels. Very easy way to obtain the number of labels is with scrollview.Panel.NumberOfViews
intScrollHeight = ((intLabelSize +10dip)*(scrollview.Panel.NumberOfViews+1.5)) + 5dip
Then you have to scrollview height:
scrollview.Panel.Height = intScrollHeight
This way the height of the scrollview would be dynamic and dependent on the number of the labels and their size.

- 1