0

我想在編輯上將維度添加到垂直方向linearlayout內的水平滾動視圖內的滾動視圖內。我的佈局基本方案belowe:將視圖添加到滾動視圖中的horizo​​ntallscrollview內的垂直線性佈局

<ScrollView 
    android:layout_width="match_parent" 
    android:layout_height="0dp" 
    android:layout_weight="1" 
    android:fillViewport="true" 
    android:fadingEdge="none"> 

    <LinearLayout 
     android:id="@+id/header" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 

     <!-- same header code --> 

    </LinearLaout> 

    <HorizontalScrollView 
     android:layout_height="wrap_content" 
     android:layout_width="wrap_content" > 

     <LinearLayout 
       android:id="@+id/list_view" 
       android:layout_height="wrap_content" 
       android:layout_width="match_parent" 
       android:orientation="vertical"/> 

    </HorizontalScrollView> 



</ScrollView> 

現在,如果我加入編程5次到list_view的LinearLayout,我只得到一個視圖,它下面的免費sapce。如果我評論Horizo​​ntallScrollView那樣:

<ScrollView 
    android:layout_width="match_parent" 
    android:layout_height="0dp" 
    android:layout_weight="1" 
    android:fillViewport="true" 
    android:fadingEdge="none"> 

    <LinearLayout 
     android:id="@+id/header" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 

     <!-- same header code --> 

    </LinearLaout> 


     <LinearLayout 
       android:id="@+id/list_view" 
       android:layout_height="wrap_content" 
       android:layout_width="match_parent" 
       android:orientation="vertical"/> 



</ScrollView> 

所有視圖都顯示正確,但它們不是橫向滾動。請給我同樣的想法如何解決這個問題。

+1

滾動型只允許生一個孩子......你要添加2這個佈局將無法正常工作 – gunar

+1

我覺得滾動視圖不允許超過一個孩子。檢查一次。 –

+0

我同意@gunar和@「Suresh Kumar Reddy Dangatla」這個佈局方案是錯誤的,但是在我的scrollview項目中,我有LinearLayout(@ + id/header)和Horizo​​ntalScrollView的合併的線性佈局 – granan

回答

1

答案是改變的LinearLayout的android:layout_width屬性中horizo​​ntalScrollview WRAP_CONTENT

+0

非常感謝。好的技術點。現在我可以在horizo​​ntalscrollview中有垂直線性佈局。 –

相關問題