2017-07-24 90 views
0

我想将textview放在搜索栏下。我使用了layout_below,但文字没有显示。Android XML layout_below不起作用

<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> 

我想edit_text_destination在FloatingSearchView下。我不知道为什么它不起作用。如果我用另一个textview替换FloatingSearchView,它可以工作。我正在努力一段时间。有人能帮助我吗?

感谢

+0

您是否检查过在库样本中实现的方式?从那里采取一些想法。也许这会帮助你。 –

+0

'FloatingSearchView'膨胀['floating_search_layout.xml'](https://github.com/arimorty/floatingsearchview/blob/a0f8fbc90d98eb1b629c6295dd2d3577412e7b1e/library/src/main/res/layout/floating_search_layout.xml),它有'match_parent/match_parent高度。 – azizbekian

回答

0

尝试使用静态高度com.arlib.floatingsearchview.FloatingSearchView 作为其搜索框采用屏幕的整体高度,其结果,由于该edit_text您使用以下获取和转移失控屏幕的..你可以通过应用scrollView进行检查,所以请尽量给出100dp或200dp的高度。 如果你想禁用editText点击searchBar并且不想给静态高度,那么你也可以使用这个。

 <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" />