2011-08-28 105 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> 
相關問題