简体   繁体   中英

How can I put the button to bottom?

I have the following layout with a Google map fragment. Now I want to put a Scrollview at the bottom but I don't know how. Please help me! Thank you so much!

<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="com.example.testgoogle.MainActivity" >

<RelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal" >

    <Button
        android:id="@+id/btn_find"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:text="@string/str_btn_find" />

    <AutoCompleteTextView
        android:id="@+id/et_location"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_toLeftOf="@id/btn_find"
        android:hint="@string/hnt_et_location"
        android:textColorHint="#d9d7d7"
        android:ems="10" >
    </AutoCompleteTextView>

</RelativeLayout>

<fragment
    android:id="@+id/map"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    class="com.google.android.gms.maps.SupportMapFragment" />
</LinearLayout>

Use RelativeLayout instead:

<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"
tools:context="com.example.testgoogle.MainActivity" >

<RelativeLayout
    android:id="@+id/search_container"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true" >

    <Button
        android:id="@+id/btn_find"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:text="@string/str_btn_find" />

    <AutoCompleteTextView
        android:id="@+id/et_location"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_toLeftOf="@id/btn_find"
        android:hint="@string/hnt_et_location"
        android:textColorHint="#d9d7d7"
        android:ems="10" >
    </AutoCompleteTextView>

</RelativeLayout>

<fragment
    android:id="@+id/map"
    android:layout_below="@+id/search_container"
    android:layout_above="@+id/scroll_view"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    class="com.google.android.gms.maps.SupportMapFragment" />

<ScrollView
    android:id="@+id/scroll_view"
    android:layout_width="match_parent"
    android:layout_height="50dp"
    android:layout_alignParentBottom="true">

    <!--Your scroll view content-->
    ...
    ...  
</ScrollView>
</RelativeLayout>

But NOTE , that your map height will depends on ScrollView 's height. It should be fixed size(ie 50dp ). But content of the ScrollView should be with wrap_content height.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM