I want my imagebutton to be aligned right but as you can see its left aligned even when the gravity="right". This is my file:
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<TableRow android:layout_height="20dp">
<ImageButton
android:id="@+id/imageButton2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:backgroundTint="@android:color/transparent"
android:graviy="right"
app:srcCompat="@drawable/ic_person_black_24dp" />
</TableRow>
</TableLayout>
How can I align my imagebutton right? I though gravity="right" would solve the problem? I tryied layout_gravity and gravity. Both dont work

First of all, you have
graviyinstead ofgravity.gravityattribute specifies "how are my children aligned inside of me" - eg. text inside TextView, Views inside Layout.layout_gravitytells parent "how I want to be positioned". Not all layouts pay respect tolayout_gravityof their children, in this case settinggravity="end"to yourTableRowworks. You can remove bothgravityandlayout_gravityfromImageButton.