我想给activity加入滚动条,xml文件格式为
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"   
     android:id="@+id/ScrollView" android:layout_width="match_parent"   
     android:layout_height="wrap_content" >    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
<LinearLayout android:id="@+id/listlinear"
              android:orientation="vertical"
              android:layout_width="fill_parent"
              android:layout_height="wrap_content">
              
              <ListView
                 android:id="@id/android:list"
                 android:drawSelectorOnTop="false"
                 android:layout_width="fill_parent"
                 android:layout_height="wrap_content"
                 />
</LinearLayout> 
 <TextView 
    android:id="@+id/neighborInfo"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
/>            
<Button 
    android:id="@+id/buttonstart"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    />    
<Button 
    android:id="@+id/buttonstop"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    />  
</LinearLayout>  
</ScrollView>
可是这样的结果是内容未全屏显示,则已经出现滚动条,致使内容未全屏显示,想实现内容大于屏幕时才出现滚动条,有人知道如何解决吗?

解决方案 »

  1.   

    android:layout_width="match_parent"   
      android:layout_height="wrap_content" 都改为fill_parent:fill_parent布局指将视图(在Windows中称为控件)扩展以填充所在容器的全部空间。wrap_content布局指根据视图内部内容自动扩展以适应其大小。
      

  2.   

    ScrollView和ListView不能同时存在,好像在android中有两个可以滚动的控件同时在在或者嵌入存在的时候有LZ所说的问题出现
      

  3.   

    scrollview 是针对自己的第一次子元素的,你的这个listview是其一个子元素,给一定的空间显示,如楼上所说,你那个listview的滚动条应该是listview自身的,你在scrollview中多添加几个button,然后scrollview的滚动条就会出现了。
      

  4.   

    我想把listView里的东西全屏显示,而不是在未全屏显示时就出现滚动条,不知道有没有什么解决方法
      

  5.   

    这是截图,其中listView里有好多项,但未全屏显示,可以把listView占的地方弄大一些吗?
      

  6.   

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent" android:layout_height="fill_parent"
    android:weightSum="1">
    <RelativeLayout android:id="@+id/relativeLayout1"
    android:layout_height="match_parent" android:layout_width="match_parent">
    <ListView android:id="@id/android:list"
    android:drawSelectorOnTop="false" android:layout_width="fill_parent"
    android:layout_height="wrap_content" android:layout_above="@+id/buttonstart"/>
    <Button android:layout_width="fill_parent"
    android:layout_height="wrap_content" android:id="@+id/buttonstart"
    android:layout_above="@+id/buttonstop"
    android:layout_alignParentLeft="true"></Button>
    <Button android:layout_width="fill_parent"
    android:layout_height="wrap_content" android:id="@+id/buttonstop"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"></Button>
    </RelativeLayout>
    </LinearLayout>