【发布时间】:2016-09-30 16:04:01
【问题描述】:
如何让视图停留在片段的底部。在下面的代码中,我有一个带有地图片段的 LinearLayout,在片段内部有一个 EditText 位于片段顶部的中心。如何在
之后立即添加 Textview<LinearLayout 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:orientation="vertical"
tools:context=".MainActivity">
<fragment
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:layout_alignParentTop="true"
android:drawableLeft="@drawable/ic_search"
android:layout_marginTop="@dimen/activity_horizontal_margin"
android:layout_marginLeft="@dimen/activity_horizontal_margin"
android:layout_marginRight="@dimen/activity_horizontal_margin"
android:hint="Search"
/>
</RelativeLayout>
</fragment>
//How can i make these Text view to the buttom
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:textColor="@color/bgprofil"
android:layout_alignParentTop="true"
android:gravity="bottom"
/>
【问题讨论】:
-
android:layout_alignParentTop="true"是与RelativeLayout 一起使用的属性android:gravity仅受TextView 内的文本影响如果要将TextView 放在EditText 下面,请将TextView 放在RelativeLayout 中
标签: java android xml android-layout