【发布时间】:2015-07-23 06:47:28
【问题描述】:
我正在尝试在(GoogleMap 虽然我不确定它的相关性...)片段顶部添加一个自定义按钮。
我不希望它本身位于其下方 - 就像我可以使用 FrameLayout 或 LinearLayout 一样 - 但我希望按钮位于顶部其父布局透明的地图...
这是我(目前)在我的 xml 中拥有的:
<fragment
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment"
map:mapType="normal"
tools:layout="@layout/activity_location">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true" // THIS DOESNT WORK !!!
android:background="#FC0" // for debug purposes
android:gravity="center|bottom" >
<Button
android:id="@+id/location_order_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/small_margin"
android:background="@drawable/nav_btn_send"
android:text=""
android:textColor="@color/black"
android:textSize="@dimen/loginFontSize" />
</RelativeLayout>
</fragment>
注意 'android:layout_alignParentBottom' 和 'android:background' 行上的 cmets...
这给了我这个结果:
现在...您可以通过代码告诉我我正在尝试将其与屏幕/地图底部对齐...但无论我做什么,它都会与顶部对齐,在 ActionBar 下方...
我已经尝试了一些我在 SO 上找到的其他方法,但这是迄今为止我想要的最接近的结果......
知道我做错了什么吗?
【问题讨论】:
标签: android android-layout android-fragments