ImageButton placement in XML

0

I have an imagebutton in a relative layout. When I put the command:

"android: layout_marginLeft="

It does what you want it to do (move away from the left border by x measure), but when I put it:

"android: layout_marginRight=" nothing happens.

Would anyone explain why? or what command should I use to make the spacing from the "start of the screen" on the right?

    
asked by anonymous 06.12.2016 / 22:21

1 answer

1

This is the setting required for your ImageButton to align according to the start and end of the screen. Check that there is no alignment with Parent , which in this case is RelativeLayout .

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">

    <ImageButton
        android:id="@+id/imageButton1"
        android:layout_width="78dp"
        android:layout_height="78dp"
        android:layout_marginLeft="10dp"
        //::layout_marginStart="10dp"
        android:layout_marginRight="10dp
        //::layout_marginEnd="10dp"
        android:src="@drawable/image_button" />

</RelativeLayout>
  • The attributes marginStart and marginEnd are optional .
06.12.2016 / 23:00