如何在Android中增加ScrollView的高度? [英] How to increase ScrollView height in Android?

查看:64
本文介绍了如何在Android中增加ScrollView的高度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


你好朋友,

我正在 ScrollView 中使用 GridView 来显示图像.在GridView中,我动态地添加了16张图像,但是 ScrollView 不能显示全部16张图像(请参见屏幕截图).

I am using GridView inside a ScrollView for displaying images. In the GridView I have 16 images which were dynamically added, but the ScrollView does not display all 16 images (see screenshot).

我希望 ScrollView 显示整个 GridView ,有人知道我该如何解决?

I want the ScrollView to display the whole GridView, does anybody know how I can fix this?

谢谢.

xml文件:

<?xml version="1.0" encoding="utf-8"?>
<merge android:layout_width="wrap_content" android:layout_height="340dip" xmlns:android="http://schemas.android.com/apk/res/android">
 <LinearLayout  android:id="@+id/LinearLayout01"  
 android:layout_width="fill_parent" 
 android:layout_height="320dip" android:orientation="vertical" 
 android:background="@color/black">
 <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/scrollview"
            android:layout_width="fill_parent"
            android:layout_height="500dip"
            android:background="#ffffff"
            android:paddingTop="10dip"
            android:paddingLeft="5dip"
            android:layout_weight="1">

 <GridView 
                    android:id="@+id/jr_lookbook_grid" android:layout_width="fill_parent"
                    android:layout_height="fill_parent" android:numColumns="4"
                    android:verticalSpacing="10dp" android:horizontalSpacing="10dp"
                    android:columnWidth="90dp" android:stretchMode="columnWidth"
                    android:adjustViewBounds="true"
                    android:background="@drawable/shape"     

                    android:gravity="center"  android:layout_weight="1"/> 
</ScrollView>

                  <Button  android:id="@+id/click"
                  android:background="@android:color/transparent"
                   android:text="Load More Pictures..."

                   android:textColor="@color/white"
                   android:layout_width="fill_parent" android:layout_height="wrap_content"
                   android:layout_centerVertical="true"  />

</LinearLayout>
  <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/LinearLayout02_img"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:layout_gravity="center"
    android:layout_alignParentBottom="true"
    android:background="@color/black"
                android:layout_alignParentLeft="true"> 

    <WebView 
        android:id="@+id/webview"

        android:layout_width="fill_parent"

        android:layout_height="fill_parent"         
        android:scrollbars="none"  

    />
    <ImageView android:id="@+id/ImageView01" 
    android:layout_gravity="center_horizontal"
    android:scaleType="centerInside"
    android:layout_width="wrap_content" 
    android:layout_height="fill_parent"

    android:adjustViewBounds="true">
</ImageView>

    </LinearLayout>
   <LinearLayout android:id="@+id/LinearLayout02"     android:background="#AA000000" 
         android:layout_width="400px"
        android:layout_height="50dip"
        android:layout_gravity="bottom"      
          >
                            <Button
                android:id="@+id/back"

                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
               android:background="@drawable/back1"
                android:layout_alignParentRight="true"
                android:layout_marginLeft="10dip"

              />

                 <Button
                  android:background="@drawable/forward5"
                android:id="@+id/next"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:layout_alignParentRight="true"
                android:layout_marginLeft="215dip"

                 />
</LinearLayout>

</merge>

推荐答案

在XML布局中使用属性 android:fillViewport ="true" 或使用方法 setFillViewport(true)用Java代码编写.

Use attribute android:fillViewport="true" in XML layout or use method setFillViewport(true) in Java code.

看看: ScrollView文档

这篇关于如何在Android中增加ScrollView的高度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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