我正在尝试对齐三个 ImageButton 属性 android:layout_marginLeft="10dp"
正在工作但是 android:layout_marginBottom="10dp"
不工作,我不是能够找出问题,请任何人帮助我...提前致谢
activity_main.xml 是:
<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>
最佳答案
你忘了加
android:layout_marginBottom="14dp"
在最后一个 ImageButton
你的代码。 :
<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>
关于android - ImageButtons 没有对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20604513/