Ich habe eine CollapsingToolbarLayout mit Recycler-Ansicht. In meiner Aktionsleiste habe ich einen Suchmenüpunkt. Aber wenn ich auf Suchsymbol klicke, erscheint das Edittext-Layout nicht.Aktionsleiste Suche in minimaler Symbolleiste Layout
Screenshots: - A) Wenn die Suche nicht geklickt wird
B) Wenn Suchsymbol geklickt wird
Mein main_activity.xml Code: -
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:id="@+id/activity_main_id"
tools:context="objectdistance.ankeshkjaisansaria.ram.sita.cameratag.MainActivity">
<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleMarginStart="48dp"
app:expandedTitleMarginEnd="64dp"
android:fitsSystemWindows="true">
<ImageView
android:id="@+id/imagetoolbar"
android:layout_width="match_parent"
android:layout_height="200dp"
android:scaleType="centerCrop"
android:fitsSystemWindows="true"
app:layout_scrollFlags="scroll"
app:layout_collapseMode="parallax"/>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:layout_collapseMode="pin" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</android.support.design.widget.CoordinatorLayout>
In meinem activity.java wird der Suchbegriff folgendermaßen behandelt: -
ActionBar action = getSupportActionBar(); //get the actionbar
action.setDisplayShowCustomEnabled(true); //enable it to display a
// custom view in the action bar.
action.setCustomView(R.layout.search_bar);//add the custom view
action.setDisplayShowTitleEnabled(false); //hide the title
Aber das Search_bar-Layout wird nicht nur angezeigt. Und auch der Titel versteckt sich nicht.
Gibt es eine andere Möglichkeit, die Suche im Menüelement zu verwenden, wenn Sie ein minimales Layout verwenden?
Geben Sie Ihren Code auch ein. –
Welcher Teil des Codes? –
Haben Sie in 'menu.xml' oder in einem Ihrer benutzerdefinierten Menüs' XML' einen Eintrag für 'Search View' hinzugefügt? –