简体   繁体   中英

Android XML layout_below doesn't work

I want to place textview under the search bar. I used layout_below, but the text is not shown.

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <com.arlib.floatingsearchview.FloatingSearchView
        android:layout_margin="@dimen/cardview_margin"
        android:id="@+id/map_floating_search_view"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:floatingSearch_close_search_on_keyboard_dismiss="true"
        app:floatingSearch_leftActionMode="showHamburger"
        app:floatingSearch_searchBarMarginLeft="@dimen/search_view_inset"
        app:floatingSearch_searchBarMarginRight="@dimen/search_view_inset"
        app:floatingSearch_searchBarMarginTop="@dimen/search_view_inset"
        app:floatingSearch_searchHint="Search for a room..."
        app:floatingSearch_showSearchKey="false"
        app:floatingSearch_suggestionsListAnimDuration="250" />


    <EditText
        android:layout_margin="@dimen/cardview_margin"
        android:id="@+id/edit_text_destination"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/map_floating_search_view"
        android:hint="To" />

    <Button
        android:id="@+id/directions_go_button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:layout_margin="@dimen/cardview_margin"
        android:text="GO!" />

    <CheckBox
        android:id="@+id/checkbox_routing_criteria"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:onClick="onCheckboxClicked"
        android:text="@string/avoid_indoor_pathways"
        android:layout_margin="@dimen/cardview_margin"
        android:textColor="@color/colorPrimary" />

</RelativeLayout>

I want edit_text_destination to be under FloatingSearchView. I am not sure why it doesn't work. If I replace FloatingSearchView by another textview, it works. I am struggling on it for a while. Could someone help me?

Thanks

Try to use static height in com.arlib.floatingsearchview.FloatingSearchView as its search box takes whole height of screen for its results due to which the edit_text you are using gets shifted below and gets out of screen.. you can check this by applying scrollView , so try to give the height like 100dp or 200dp. OR if you want to disable the editText on click of searchBar and don't want to give static height then you can also use this.

        <EditText
            android:id="@+id/edit_text_destination"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="99dp"
            android:hint="To"
            android:layout_alignParentTop="true"
            android:layout_alignRight="@+id/directions_go_button"
            android:layout_alignEnd="@+id/directions_go_button"
            android:layout_alignLeft="@+id/checkbox_routing_criteria"
            android:layout_alignStart="@+id/checkbox_routing_criteria" />

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