2014-02-24 157 views
0

我有這個XML.I想要在Java代碼的XML代碼的linearlayoutUp中包含動態按鈕,並且我希望此按鈕以水平位置出現,任何想法都會垂直懸掛到水平在動態佈局中更改位置按鈕

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:background="#FFCCCCCC" 
android:orientation="vertical" 
tools:context=".MainActivity" > 

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

    <ScrollView 
    android:id="@+id/scrollView1" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:scrollbars="vertical" > 

     </ScrollView> 

</LinearLayout> 

<com.example.nuevo.ControladorView 
    android:id="@+id/drawing" 
    android:layout_width="match_parent" 
    android:layout_height="0dip" 
    android:layout_marginBottom="3dp" 
    android:layout_marginLeft="5dp" 
    android:layout_marginRight="5dp" 
    android:layout_marginTop="3dp" 
    android:layout_weight="0.83" /> 

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

</LinearLayout> 

</LinearLayout> 
+0

什麼是你想第二個'LinearLayout'和'ScrollView'辦? –

+0

線性是創建按鈕的區域。按鈕的數量可能很高,所以我介紹layout4內的scrollView – user3232094

+0

嘿!我刪除了滾動螞蟻它的作品,但我想包括滾動,我怎麼能做到這一點?謝謝,謝謝! – user3232094

回答

0

如果您想使用ScrollView,請將其放在佈局中。此外,您應該使用HorizontalScrollView,因爲您的列表是水平的。

試試這個:

<HorizontalScrollView 
    android:id="@+id/scrollView1" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" > 

    <LinearLayout 
     android:id="@+id/linearlayoutUp" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" > 
    </LinearLayout> 
</HorizontalScrollView> 
+0

yeyyy !!它的作品完美!謝謝!!! – user3232094

+0

我想做兩個按鈕一個上下一個和所有相同的功能,用tableLayout代替線性? – user3232094

+0

我有一個帶有畫布和兩個線性佈局的XML文件,一個放在畫布上,另一個放在底部。我想在頂部和底部有四個按鈕,當我點擊一個按鈕(播放按鈕)時,我希望線性更改按鈕 謝謝 – user3232094