2015-05-27 42 views

回答

2

它不垂直,其水平是

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

    <HorizontalScrollView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 
    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="horizontal"> 
     // Add your ImageButtons 
    </LinearLayout> 
</HorizontalScrollView> 

+0

如果我現在在這個LinearLayout中放置像ImageButton這樣的元素,它們將會垂直滾動嗎? –

+0

是的,試試吧。如果我的答案有效,那就接受它。 – Exigente05

+0

可悲的是它沒有:/ –

0

你必須滾動視圖設置爲

android:fillViewport="true" 

下面是完整的代碼

<ScrollView 
      xmlns:android="http://schemas.android.com/apk/res/android" 
      xmlns:tools="http://schemas.android.com/tools" 
      android:id="@+id/myscrollView" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:fillViewport="true"> 
</ScrollView>