だから、状況はこれです:AppBarLayoutは断片
私はすでに同じスクロール動作と私のフラグメントにCoordinatorLayoutとAppBarLayoutを持って、私のメインの活動でアプリケーションバーのスクロール動作を実装する必要がありますが、。ここで
は、レイアウトの両方からxmlです:activity_main:
<android.support.design.widget.CoordinatorLayout 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="#EBEDEC">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/toolbar_open_nav"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:src="@drawable/filter_icon" />
<RelativeLayout
android:id="@+id/main_activity_images_relative"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/toolbar_fencity_image"
android:layout_width="200dp"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:layout_margin="@dimen/layout_padding"
android:src="@drawable/toolbarimg"
android:visibility="gone" />
</RelativeLayout>
</RelativeLayout>
</android.support.v7.widget.Toolbar>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<FrameLayout
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="@android:color/transparent" />
<com.bitage.carlo.fencity.ui.view.BottomMenuView
android:id="@+id/bottom_menu"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize" />
</LinearLayout>
</RelativeLayout>
とフラグメントのxml:今すぐ
<?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"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="?attr/actionBarSize"
android:orientation="vertical">
<android.support.design.widget.AppBarLayout
android:id="@+id/novita_app_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:id="@+id/novita_search_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/background"
app:layout_scrollFlags="scroll|enterAlways|snap">
<EditText
android:id="@+id/search_edit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/layout_padding"
android:background="@null"
android:hint="@string/search"
android:imeOptions="actionDone"
android:paddingEnd="@dimen/layout_padding"
android:paddingLeft="@dimen/padding_start"
android:paddingRight="@dimen/layout_padding"
android:paddingStart="@dimen/padding_start"
android:singleLine="true" />
<ImageView
android:id="@+id/search_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="@dimen/layout_padding"
android:layout_marginStart="@dimen/layout_padding"
android:src="@drawable/ic_search" />
</RelativeLayout>
</android.support.design.widget.AppBarLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<android.support.v7.widget.RecyclerView
android:id="@+id/places_recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="@android:color/transparent"
android:src="@drawable/nav_shadow" />
</RelativeLayout>
</android.support.design.widget.CoordinatorLayout>
、私が滞在するために、これを必要とします可能であれば同じ、ちょうど何とかスクロール動作を追加するapp:layout_scrollFlags="scroll|enterAlways|snap"
oolbarはこのフラグメント内でのみ検索されますが、フラグメントからの検索はまだ同じ動作をします。
どうすればこの問題を解決できますか?