Reputation: 331
I referred most of the questions in Stackoverflow related to this topic and successfully placed my Linear Layout in a ScrollView. But I can't scroll it. The outline of my Activity is-
Here is the XML code of ScrollView-
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" >
<LinearLayout
android:id="@+id/linearLayoutUP1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_weight="1"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:orientation="vertical" >
<TextView
android:id="@+id/textViewUP1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/Chocolate"
android:gravity="center"
android:padding="10dp"
android:text=" "
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="@color/Black"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:orientation="vertical" >
<TextView
android:id="@+id/textViewUP2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/Chocolate"
android:gravity="center"
android:padding="10dp"
android:text="User ID : "
android:textColor="@color/White"
android:textSize="16sp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:orientation="vertical" >
<TextView
android:id="@+id/textViewUP4"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/Chocolate"
android:gravity="center"
android:padding="10dp"
android:text="Gender : "
android:textColor="@color/White"
android:textSize="16sp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:orientation="vertical" >
<TextView
android:id="@+id/textViewUP3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/Chocolate"
android:gravity="center"
android:padding="10dp"
android:text="Your Groups"
android:textColor="@color/White"
android:textSize="16sp"
android:textStyle="bold" />
<GridView
android:id="@+id/gridViewUP1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:numColumns="1"
android:padding="5dp" >
</GridView>
</LinearLayout>
</LinearLayout>
</ScrollView>
As you can see there is a GridView in the last LinearLayout. This GridView was scrollable before adding ScrollView. After adding ScrollView the layout named 'linearLayoutUP1' cannot be scrolled. How can I make it scrollable vertically ?
Upvotes: 2
Views: 1828
Reputation: 14810
Try hardcoding the height for the first LinearLayout..ie change wrap_content
to some 1000dp or so. This will make it scrollable. I'm not at all sure whether this is the right way to solve the problem..But was telling you what I did when I faced the same situation.
Also, if you are using android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
..try changing that to android:theme="@android:style/Theme.NoTitleBar"
..ie without fullscreen...
Again, check if there is android:windowSoftInputMode="adjustPan"
for your activity tag in manifest..if yes try after removing that.
These are the solutions which i tried and worked when i faced a similar situatuion.
android activity always start scrolled to the bottom-to solve this problem please add android:focusableInTouchMode="true"
to your LinearLayout
..
Upvotes: 1
Reputation: 61
It is not recommended to you any kind of scrollable view inside a ScrollView.
You may want to check this out in your case and see if it works.
http://lubosplavucha.com/java/2014/05/05/gridview-scrollview-issue/
Upvotes: 0
Reputation: 8685
I think nesting scrollable views in Android is considered bad design, and may not work properly. GridViews are inherently scrollable.
If you want to keep it, try looking here: Problems with GridView inside ScrollView in android
Upvotes: 2