Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/192.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 将按钮与屏幕右下角对齐?_Android_Xml_Android Studio - Fatal编程技术网

Android 将按钮与屏幕右下角对齐?

Android 将按钮与屏幕右下角对齐?,android,xml,android-studio,Android,Xml,Android Studio,我在“操作”按钮右侧有一个提交按钮: 我尝试使用以下代码: android:gravity="bottom|right" 但它不起作用,它仍然停留在同一个地方 我的完整代码如下: <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="bottom" android:keepScreenOn="true" a

我在“操作”按钮右侧有一个提交按钮:

我尝试使用以下代码:

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"
    />

即使使用上面的代码,布局仍然与图像相同。我怎样才能解决这个问题


修复:由于Egor N,添加了android:layout\u alignParentRight=“true”。android:layout\u alignParentRight=“true”

。但是,您应该摆脱android:layout\u toRightOf=“@id/btnSelectPhoto”


android:gravity
不起作用,因为该值应用于视图内的内容(按钮内的文本)。

您可以在两个botton之间使用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>

看起来它起作用了,我对“操作”按钮做了同样的操作,但改为:“android:layout\u alignParentRight=“true”。谢谢你的帮助