2016-10-20 5 views
0

私はトップレイアウトのSearchViewを入れたいです。私はSearcViewでMyActivityを持っています。その下にはRecyclerViewがあります。私がMyActivityを開くと、最初にRecyclerViewが表示されます。 MyActivityをどのように設定すればMyActivityを開くと最初のSearchViewが表示されるのですか?Android Searchview on the top

<ScrollView 
android:layout_height="match_parent" 
android:layout_width="match_parent" 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:fillViewport="true"> 

<LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="50dp" 
     android:orientation="vertical"> 
     <SearchView 
      android:layout_width="match_parent" 
      android:layout_height="50dp" 
      android:queryHint="Evento" 
      android:id="@+id/cercaEvento"/> 

    </LinearLayout> 
...... 
</ScrollView> 
+0

置きますアクションバーやツールバーのSearchViewをあなたの問題を解決するためです。その後、常に上に残ります。 – vidulaJ

+0

私の問題の解決策はありますか? – Fra87

+0

うん。 SearchViewは、メニュー項目に配置する必要があります。作業コードを与えることができます。 – vidulaJ

答えて

0
<RelativeLayout> 
    <SearchView> 
    <RecyclerView> 
</RelativeLayout> 
0
<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="#e5e5e5" 
    android:orientation="vertical"> 

    <android.support.v7.widget.SearchView 
     android:id="@+id/cercaEvento" 
     android:layout_margin="16dp" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:padding="8dp" 
     android:queryHint="Evento" /> 

    <android.support.v7.widget.RecyclerView 
     android:id="@+id/mList" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" /> 
</LinearLayout> 
+0

なぜ機能しないのですか? – Fra87

+0

エラーログを提供できますか? あなたは依存関係を追加しましたか? 'com.android.support:cardview-v7:25.0.0'をコンパイルします。 com.android.support:design:25.0.0 'をコンパイルします。 – stefanodp91

+0

私はcardviewを使用しません。私はtextviewを使用します。私は2つのリストビュー私はrecyclerviewを使用しています。私は、それがsearchviewで始まり、recyclerviewで始まらないときは、私が望む – Fra87