2

I am new to Android. I am stuck off in understanding the concept of using weight sum with weighted LinearLayouts. Have skimmed through a number of related questions on StackOverflow but still haven't found the solution.

Scenario
I have an activity layout page with number of components . The components are oriented vertically in the linear layout according to their layout_weights.

Code

<ScrollView fillViewPort="true" scrollBars="true">
<LinearLayout android:weightSum="150">
<!-- Various components present here each assigned layout_weight attribute
Total sum being 150 itself -->
</LinearLayout>
</ScrollView>

Question

My question is that how can I use scroll View and weightSum together such that a total of weightSum=100 displays on one page and for the rest 50 user needs to scroll down.

Jordi Castilla
  • 26,609
  • 8
  • 70
  • 109
user2653926
  • 610
  • 7
  • 23

2 Answers2

0

This is the one idea how it could possible

 <LinearLayout weightsum="150" android:orientation="vertical">
      <LinearLayout layout_weight="100">
         //your LinearLayout 
      </LinearLayout>
      <ScrollView Layout_weight="50">
         //your scrollview layout
     </ScrollView>
    </LinearLayout>
Asad Mehmood
  • 315
  • 1
  • 3
  • 20
0

Documentation says that the mission of weightSum is managing spaces below/under all the items of LinearLayout. Moreover, the weight does not purpose for specifying exact size of layout (but only for relative size), so nor for the paging. If you want to scroll Views page-by-page, you can use ViewPager.

anil
  • 2,083
  • 21
  • 37