如何在Android活动中垂直滚动 [英] How to vertical scroll in Android Activity

查看:133
本文介绍了如何在Android活动中垂直滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的布局如下:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:isScrollContainer="true"
    android:orientation="vertical">

    <Gallery
        android:id="@+id/gallery"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:gravity="bottom" />

    <LinearLayout
        android:id="@+id/chart"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:orientation="horizontal" />
    
</LinearLayout>

画廊在运行时填充,并且当用户点击某个项目时,我用一系列图像填充LinearLayout.
我想垂直滚动,但是如果我在用户点击图库时添加ScrollView,则不会再填充LinearLayout.

Gallery is filled at runtime and when the user taps on an item I fill the LinearLayout with a series of images.
I would like to scroll vertically but if I add a ScrollView when the user taps the Gallery the LinearLayout is not filled anymore.

正常吗?如何添加垂直滚动?

Is it normal? How can I add a vertical scroll?

推荐答案

<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>

这篇关于如何在Android活动中垂直滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆