2011-08-28 107 views
2

当以横向/横向模式显示时,我有view/form/activity,比屏幕大。我想知道用户可以向下滚动视图的方式是什么?滚动Android视图/大于屏幕大小的表格

当前,我所有的小部件都以线性布局作为研究员。

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

<Widget1></Widget1> 
<Widget2></Widget2> 
<Widget3></Widget3> 
<Widget4></Widget4> 
<Widget5></Widget5> 
</LinearLayout> 

回答

3

首先感谢@Dimitris Makris在帮助我找到了正确的方向,编写代码为我。但是我为自己找到的正确解决方案就是这样。

<?xml version="1.0" encoding="utf-8"?> 
<ScrollView android:id="@+id/scrollView1" 
android:layout_width="fill_parent" android:layout_height="fill_parent" 
xmlns:android="http://schemas.android.com/apk/res/android"> 

<LinearLayout 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 

<Widget1/> 
<Widget2/> 

</LinearLayout> 
</ScrollView> 
6

如果我理解正确你的问题:你可以有一个滚动型你的LinearLayout以外,有你的LinearLayout,在那里你可以添加你的Widgets内Horizo​​ntalScrollView。这将允许您滚动左右和上下。

示例代码:

<ScrollView android:id="@+id/scrollView1" 
android:layout_width="fill_parent" android:layout_height="fill_parent" 
xmlns:android="http://schemas.android.com/apk/res/android"> 
<LinearLayout android:id="@+id/linearLayout1" 
    android:layout_width="match_parent" android:layout_height="match_parent" 
    android:orientation="vertical"> 
    <HorizontalScrollView android:id="@+id/horizontalScrollView1" 
     android:layout_width="wrap_content" android:layout_height="wrap_content"> 
     <LinearLayout android:id="@+id/linearLayout2" 
      android:layout_width="match_parent" android:layout_height="match_parent" 
      android:orientation="horizontal"> 
      <Widget1/> 
      <Widget2/> 
     </LinearLayout> 
    </HorizontalScrollView> 
</LinearLayout> 
</ScrollView> 
+0

并设置了android:定位属性为水平/垂直按照您的要求 –

+0

@Dimitris Markis - 你能给出的示例代码?我完全困惑。 – itsaboutcode

+0

@itsaboutcode示例代码补充说明 –

0

什么我的情况是工作把滚动型为最外层的观点, 其次Horizo​​ntalScrollView,然后嵌套的一切。

*注意 - ScrollView不支持水平滚动,因此嵌套的Horizo​​ntalScrollView。

<ScrollView 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/scroller"  
    android:layout_width="fill_parent"  
    android:layout_height="fill_parent" 
    android:fillViewport="true"> 
    <HorizontalScrollView 
    android:id="@+id/horizontalScrollView1" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 
    <LinearLayout 
     ... 
    </LinearLayout> 
    </HorizontalScrollView> 
</ScrollView> 
相关问题