I'm trying to align a button to the right of the size of the layout it's in. I've tried Gravity and it doesn't do it for me. Any suggestion?
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/LayoutEditText"
android:orientation="horizontal">
<Button
android:id="@+id/buttonInvertirTick"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_marginTop="10dp"
android:layout_marginLeft="20dp"
android:background="@drawable/success"
android:gravity="right"/>
</LinearLayout>
You would have to use
android:layout_gravity
, since this is the one that marks the position of an element with respect to the parent element, instead ofandroid:gravity
, which indicates the position of its view (for example, the text you have on the button, which belongs to the view of the same).