2014-11-01 84 views
1

我有一個在這裏提交的「操作」按鈕右側的按鈕:將一個按鈕對齊屏幕的右下角?

Submit Button

我試圖使用代碼:

android:gravity="bottom|right" 

,但它不工作,它仍然停留在同一個地方。

我完整的代碼是這樣的:

<Button 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:gravity="bottom" 
    android:keepScreenOn="true" 
    android:textSize="25dp" 
    android:padding="30dp" 
    android:textStyle="bold" 
    android:textAlignment="center" 
    android:text="@string/select_action" 
    android:id="@+id/btnSelectPhoto" 
    android:layout_alignParentBottom="true"/> 

<Button 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_toRightOf="@id/btnSelectPhoto" 
    android:keepScreenOn="true" 
    android:gravity="bottom|right" 
    android:padding="30dp" 
    android:text="@string/submit" 
    android:textSize="25dp" 
    android:textStyle="bold" 
    android:id="@+id/btnSubmit" 
    android:layout_alignParentBottom="true" 
    /> 

即使上面的代碼,佈局仍是一樣的圖像。我怎樣才能解決這個問題?

修正:將機器人:layout_alignParentRight = 「真」,由於葉戈爾N.

回答

2

android:layout_alignParentRight="true"應該做的工作。但是,你應該擺脫android:layout_toRightOf="@id/btnSelectPhoto"

android:gravity沒有工作,因爲這個值應用於視圖內的內容(按鈕內的文本)。

+0

看起來像它的工作,我也做了同樣的事情「操作」按鈕,但: 「機器人:layout_alignParentRight =「true」' 改爲。謝謝您的幫助 – 2014-11-01 13:16:15

0

您可以使用兩個bottons

例如之間的simlpe查看:

<LinearLayout 
    android:orientation="horizontal" 
    android:weightSum="3" 
    android:layout_width="match_parent" 
    android:layout_height="80dp" 
> 
    <Button 
     android:layout_width="0dp" 
     android:layout_height="match_parent" 
     android:layout_weight="1"/> 

    <View 
     android:layout_width="0dp" 
     android:layout_height="match_parent" 
     android:layout_weight="1"/> 

    <Button 
     android:layout_width="0dp" 
     android:layout_height="match_parent" 
     android:layout_weight="1"/> 
</LinearLayout>