I have a fragment that contains a google map:
<com.google.android.gms.maps.MapView
android:id="@+id/mapview"
android:layout_width="match_parent"
android:layout_height="match_parent"
map:cameraZoom="13"
map:mapType="normal"
map:uiZoomControls="false"
map:uiRotateGestures="true"
map:uiScrollGestures="true"
map:uiZoomGestures="true"
map:uiTiltGestures="false" />
the map takes up the entire screen and has mylocation enabled:
map.setMyLocationEnabled(true);
The following code should align the mylocation button to the top-left of the screen:
// Get the mylocation button view
View locationButton = ((View) mapview.findViewById(Integer.parseInt("1")).getParent()).findViewById(Integer.parseInt("2"));
RelativeLayout.LayoutParams rlp = (RelativeLayout.LayoutParams) locationButton.getLayoutParams();
rlp.addRule(RelativeLayout.ALIGN_PARENT_TOP);
rlp.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
however - this only aligns the button to the top center of the screen. However, if I add this:
if (Build.VERSION.SDK_INT >= 17) {
rlp.addRule(RelativeLayout.ALIGN_PARENT_START);
}
then it aligns to the left properly. The problem is that ALIGN_PARENT_START can't be used programmatically before api 17 and I need to support from a lower api level. Why isn't align_parent_left working on it's own to align the button to the left?