2016-06-15 111 views
1

是否可以從代碼中設置晶圓廠的位置?浮動動作按鈕的定位

比如我有這2個晶圓廠:

FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); 
FloatingActionButton editFab = (FloatingActionButton) findViewById(R.id.editFab); 

「FAB」 是默認的工廠,那當屬例子後,我創建一個空白活動和editFab是我的晶圓廠

<android.support.design.widget.FloatingActionButton 
     android:id="@+id/editFab" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="bottom" 
     android:layout_margin="16dp" 
     android:clickable="true" 
     /> 

enter image description here

是否可以將「editFab」放在代碼的「fab」按鈕上方?或者我必須在xml佈局中做到這一點?

+0

爲什麼你想把它放在fab之上?你爲什麼不用'fab'? –

+2

@jankigadhiya我想要有2個工廠 –

+1

在相對佈局中添加晶圓廠,並將其放在您想要的位置。 –

回答