2013-01-02 161 views
-6

我正在嘗試開發一個簡單的slotmachine,但我遇到了佈局問題。 我真的不知道如何繪製佈局,你可以看到在這pic 任何人都可以幫助我嗎?如何繪製此佈局


感謝您的幫助。 我已經嘗試了你建議的那種嵌套的佈局佈局,問題是隻顯示第一個線性佈局!沒有顯示三個imageView的lineralayout,這就是爲什麼我是havengi問題。我以爲我做錯了,因爲它

在第一次lineraLayout之後,沒有其他顯示!

+0

好了,[你有什麼試過嗎?(http://mattgemmell.com/2008/12/08/what -have-you-tried /) –

+0

通過相同的努力,您將能夠創建XML佈局。 –

+0

我嘗試了RelativeLayout,但我無法將3 ImagView放在那個位置。我使用android:layout_toRightOf,android:layout_below,但是我無法將這些imageview放在那個位置。 然後我嘗試使用LinearLayout,但我有同樣的問題。我必須在3個不同的行上顯示對象 – MDP

回答

2

與此模板來吧:

但始終顯示你的努力提出任何問題時:

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="horizontal" 
    android:weightSum="1"> 
<TextView 
    android:layout_width="0dp" 
    android:layout_height="wrap_content" 
    android:layout_weight="0.4" 
    android:text="@string/hello_world" /> 
<Button 
    android:layout_width="0dp" 
    android:layout_height="wrap_content" 
    android:layout_weight="0.2" 
    android:text="click"/> 
<TextView 
    android:layout_width="0dp" 
    android:layout_height="wrap_content" 
    android:text="hi" 
    android:gravity="center" 
    android:layout_weight="0.2" /> 
<Button 
    android:layout_width="0dp" 
    android:layout_height="wrap_content" 
    android:layout_weight="0.2" 
    android:text="click"/> 

</LinearLayout> 

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="horizontal" 
    android:layout_marginTop="20dp" 
    android:gravity="center" 
    android:weightSum="1"> 

    <ImageView 
     android:layout_width="0dp" 
     android:layout_weight="0.3" 
     android:background="@android:color/darker_gray" 
     android:layout_marginLeft="5dp" 
     android:layout_height="100dp"/> 
    <ImageView 
     android:layout_width="0dp" 
     android:layout_weight="0.3" 
     android:layout_marginLeft="2dp" 
     android:background="@android:color/darker_gray" 
     android:layout_height="100dp"/> 
    <ImageView 
     android:layout_width="0dp" 
     android:layout_weight="0.3" 
     android:layout_marginLeft="2dp" 
     android:background="@android:color/darker_gray" 
     android:layout_height="100dp"/> 
</LinearLayout> 

<Button 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_marginTop="25dp" 
    android:layout_gravity="center" 
    android:text="Button"/> 

+0

@Matteo Depasquali:如果您有任何想法,那麼您可以接受答案 –