Reputation: 3592
I have an image and on top of it (bottom-right) placed a button which is constrained to the right and bottom of the image. I would like to move the button 5dp to the right and bottom, so it sits a bit off, outside of the contours of the image.
Screenshot of the current layout, where the X button is placed within the contours:
XML of the button (inside a constraint layout):
<Button
android:id="@+id/deletePic1"
android:layout_width="@dimen/delete_picture_button_size"
android:layout_height="@dimen/delete_picture_button_size"
android:background="@drawable/delete_button"
app:layout_constraintBottom_toBottomOf="@+id/profilePic1"
app:layout_constraintEnd_toEndOf="@+id/profilePic1"
/>
Upvotes: 0
Views: 219
Reputation: 38
You can use android:translationX
and android:translationY
<Button
android:id="@+id/deletePic1"
android:layout_width="@dimen/delete_picture_button_size"
android:layout_height="@dimen/delete_picture_button_size"
android:background="@drawable/delete_button"
android:translationX="5dp"
android:translationY="5dp"
app:layout_constraintBottom_toBottomOf="@+id/profilePic1"
app:layout_constraintEnd_toEndOf="@+id/profilePic1"
/>
Upvotes: 1
Reputation: 156
try add
app:layout_constraintTop_toBottomOf="@+id/profilePic1"
app:layout_constraintStart_toEndOf="@+id/profilePic1"
this is not 5dp, but it sits a bit off, outside of the contours of the image
Upvotes: 1