Reputation: 1181
I am trying to align three ImageButton the attribute android:layout_marginLeft="10dp"
is working but android:layout_marginBottom="10dp"
is not working, I am not able to find out the issue, Please anybody help me...Thanks in advance
activity_main.xml is:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent"
tools:context=".MainActivity" >
<fragment
android:id="@+id/map_fragment"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true" />
<RelativeLayout
android:id="@+id/relativeLayout1"
android:layout_width="350dp"
android:layout_height="40dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginTop="20dp"
android:background="@drawable/card_for_edittext" >
<ImageButton
android:id="@+id/button_go"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:background="@android:color/transparent"
android:contentDescription="@string/save_button"
android:src="@drawable/ic_save" />
<View
android:layout_width="0.5dp"
android:layout_height="20dp"
android:layout_alignBottom="@+id/button_go"
android:layout_marginBottom="9dp"
android:layout_marginLeft="15dp"
android:layout_toLeftOf="@+id/button_go"
android:background="@android:color/darker_gray" />
<EditText
android:id="@+id/enteraddress"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="5dp"
android:background="@android:color/transparent"
android:ems="10"
android:hint="@string/enter_address" >
</EditText>
</RelativeLayout>
<ImageButton
android:id="@+id/btnCurrentLocation"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:background="@drawable/box_96"
android:contentDescription="@string/mapView_Button"
android:src="@drawable/ic_current_location" />
<ImageButton
android:id="@+id/btnRefresh"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="14dp"
android:background="@drawable/box_96"
android:contentDescription="@string/refresh_button"
android:src="@drawable/ic_refresh"
android:text="@string/refresh_button" />
<ImageButton
android:id="@+id/btnListview"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:background="@drawable/box_96"
android:contentDescription="@string/mapView_Button"
android:src="@drawable/ic_location_list" />
</RelativeLayout>
Upvotes: 2
Views: 123
Reputation: 6942
You forgot to add
android:layout_marginBottom="14dp"
in the last ImageButton
your code. :
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent"
tools:context=".MainActivity" >
<fragment
android:id="@+id/map_fragment"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true" />
<RelativeLayout
android:id="@+id/relativeLayout1"
android:layout_width="350dp"
android:layout_height="40dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginTop="20dp"
android:background="@drawable/card_for_edittext" >
<ImageButton
android:id="@+id/button_go"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:background="@android:color/transparent"
android:contentDescription="@string/save_button"
android:src="@drawable/ic_save" />
<View
android:layout_width="0.5dp"
android:layout_height="20dp"
android:layout_alignBottom="@+id/button_go"
android:layout_marginBottom="9dp"
android:layout_marginLeft="15dp"
android:layout_toLeftOf="@+id/button_go"
android:background="@android:color/darker_gray" />
<EditText
android:id="@+id/enteraddress"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="5dp"
android:background="@android:color/transparent"
android:ems="10"
android:hint="@string/enter_address" >
</EditText>
</RelativeLayout>
<ImageButton
android:id="@+id/btnCurrentLocation"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_marginBottom="14dp"
android:layout_marginLeft="10dp"
android:background="@drawable/box_96"
android:contentDescription="@string/mapView_Button"
android:src="@drawable/ic_current_location" />
<ImageButton
android:id="@+id/btnRefresh"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="14dp"
android:background="@drawable/box_96"
android:contentDescription="@string/refresh_button"
android:src="@drawable/ic_refresh"
android:text="@string/refresh_button" />
<ImageButton
android:id="@+id/btnListview"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_marginBottom="14dp"
android:layout_marginRight="10dp"
android:background="@drawable/box_96"
android:contentDescription="@string/mapView_Button"
android:src="@drawable/ic_location_list" />
</RelativeLayout>
Upvotes: 1
Reputation: 6557
You need to keep the android:layout_marginBottom
arrtibut = 10 dp for all the 3 buttons like this:
<ImageButton
android:id="@+id/btnCurrentLocation"
...other attributes...
android:layout_marginBottom="10dp"
...other attributes... />
<ImageButton
android:id="@+id/btnRefresh"
...other attributes...
android:layout_marginBottom="10dp"
...other attributes.../>
<ImageButton
android:id="@+id/btnListview"
...other attributes...
android:layout_marginBottom="10dp"
...other attributes... />
You kept 10dp only for first button, 14dp for 2nd button, and didn't specify layout_marginBottom
for 3rd button.
You should add 10dp for all 3 buttons
Upvotes: 0