Animesh Jena
Animesh Jena

Reputation: 1551

ScrollView is not Scrolling down

I know its a very basic issue. I still can't resolve it. I have a Scrollview below a title view and the Scrollview is not at all scrolling. I will post my codes below. Please have a look.

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/page_background"
android:clickable="true"
android:orientation="vertical"
>

 <RelativeLayout
   android:layout_width="match_parent"
   android:layout_height="?android:attr/actionBarSize"
   android:gravity="center_vertical"
   android:layout_weight="0"
   android:clickable="true"
   android:background="@color/button_colour">
 </RelativeLayout>

 <ScrollView
  android:layout_width="match_parent"
  android:layout_height="0dp"
  android:layout_weight="1"
  android:fillViewport="true"
 >
 <LinearLayout
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   android:weightSum="14"
   android:padding="2dp"
   android:clickable="true"
   android:orientation="vertical">
 </LinearLayout>

 </ScrollView>

 </LinearLayout>

Upvotes: 1

Views: 46

Answers (1)

SpiritCrusher
SpiritCrusher

Reputation: 21043

There is no use of android:layout_weight in this case . And also you do not have to use android:layout_weight inside ScrollView. If you use Views will be wrap inside the ViewGroup and won't scroll. And fill_parent is depricated Use match_parent.

Use the layout below:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/linearLayout"
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="match_parent">

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="?android:attr/actionBarSize"
    android:background="@color/colorPrimary"
    android:clickable="true"
    android:gravity="center_vertical">


</RelativeLayout>

<ScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fillViewport="true">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/colorAccent"
        android:orientation="vertical"
        android:padding="2dp"
        >
        <!--Other views goes here without weight-->

    </LinearLayout>
</ScrollView>
</LinearLayout>

Upvotes: 1

Related Questions