How to vertically scroll activity in Android

I have the following layout:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:isScrollContainer="true"> <Gallery android:id="@+id/gallery" android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="bottom"/> <LinearLayout android:id="@+id/chart" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" /> </LinearLayout> 

The gallery is populated at runtime, and when the user clicks on an item, I populate LinearLayout with a series of images. I would like to scroll vertically, but if I add a ScrollView when the user deletes the gallery, LinearLayout will no longer fill.

This is normal? How can I add vertical scroll?

Thank you and congratulations.

+7
source share
3 answers
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <ScrollView android:id="@+id/ScrlView" android:layout_width="fill_parent" android:layout_height="fill_parent" > <LinearLayout android:id="@+id/layoutForScroll" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="wrap_content" > <Gallery android:id="@+id/gallery" android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="bottom"/> <LinearLayout android:id="@+id/chart" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" /> </LinearLayout> </ScrollView> </LinearLayout> 
+13
source

There can only be one child in your vertical scroll view, which means that you need to wrap the gallery view and line chart with another linerLayout, which should then be wrapped in scrollView.

When you add new views, you may need to update the displayed scroll status or make it invalid, try something like this to expand it accordingly.

0
source

You must expand the Gallery class, and in the drawing procedure, rotate the canvas 90 degrees. Then a few adoptions are required, such as changing the onTouch event and a few more. After that, there will be several problems with the layout (since he still wants to draw the layout in his parameters). So I put it in LinearLayout and fixed the layout size. Thus, the final vertical gallery is actually the linear layout in which the gallery is placed. I implemented it and it works quite well. You will only need to turn everything that you put into it 90 degrees in a different direction. The compromise is really a bit, so you can expand each view that you want to insert into it, and simply turn it in a different direction in the drawing procedure.

0
source

All Articles