2014-11-01 83 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>