I have a problem with ScrollView component.
How to prevent stretching of ScrollView?
I have a LinearLayout with weight_sum = 2 and in it an ImageView with layout_weight = 1 and a ScrollView with layout_weight = 1
It looks fine when ScrollView has 2, 3 elements, that means that it doesn’t need to scroll.
When I add more elements the ScrollView resizes, its height gets bigger and bigger, and the ImageView gets smaller.
Height of those items is wrap_content.
How to prevent that problem?
Code:
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
android:layout_weight="3"
android:orientation="vertical"
android:weightSum="2" >
<ImageView
android:id="@+id/pregamePlayerNames"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/en_player_names" />
<ScrollView
android:id="@+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_weight="1" >
<LinearLayout
android:id="@+id/pregamePlayerNamesScroll"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/home_player_names_ram"
android:orientation="vertical" >
</LinearLayout>
</ScrollView>
</LinearLayout>
If you are giving
weightto the layout no need to specify theheight