2011-05-29 87 views
1

我想做一個可滾動的佈局,其中包含許多相關佈局和按鈕。 (見下面的例子)。但我每次做一個滾動視圖時,它說滾動視圖可以包含一個子......使用按鈕滾動佈局!

滾動型

Relativelayouts1 
    Button1 
Relativelayouts2 
    Button2 
Relativelayouts3 
    Button3 
Relativelayouts4 
    Button4 

滾動型(END)

回答

1

這個問題的解決是簡單...用一個佈局包裝子佈局。例如,如下所示。

ScrollView 
    LinearLayout 
     Relativelayouts1 
      Button1 
     Relativelayouts2 
      Button2 
     Relativelayouts3 
      Button3 
     Relativelayouts4 
      Button4 
+0

謝謝!現在我可以完成我正在做的事情! – IntelSoftApps 2011-05-29 20:49:37

0

你爲什麼想要4個RelativeLayouts?它打破了佈局的目的。最有可能的是,您可以使用相同的結果:

<ScrollView> 
    <RelativeLayout> 
    <Button/> 
    <Button/> 
    <Button/> 
    <Button/> 
    </RelativeLayout> 
</ScrollView> 

這樣可以避免浪費寶貴的資源來生成無用的視圖。

把你的時間來閱讀這篇文章:http://www.curious-creature.org/2009/02/22/android-layout-tricks-1/(和部分2和3也)

+0

這是按鈕佈局方式。他們不是另一個人的榜樣。他們在特定的羣體。 – IntelSoftApps 2011-05-29 20:49:15

+0

這就是RelativeLayout的意思。 – Aleadam 2011-05-30 04:50:06