I have a submit button here on the right of "Action" Button:
I've tried to use the code:
android:gravity="bottom|right"
but it doesn't work, and it still stays on the same place.
My full code is this:
<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"
/>
Even with the code above, the layout is still the same as the image. How can I fix this?
Fixed: Added android:layout_alignParentRight="true", Thanks to Egor N.
android:layout_alignParentRight="true"
should do the job. But, you should get rid of android:layout_toRightOf="@id/btnSelectPhoto"
.
android:gravity
didn't work, because this value is applied to content inside the view (text inside a button).
You can use a simlpe View between the two bottons
for example:
<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>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.