【发布时间】:2017-02-27 15:35:56
【问题描述】:
我想消失 toolbar菜单折叠 appBarlayout,但我不知道怎么做。
我的代码在这里:
public class MainFragment extends BaseFragment implements Toolbar.OnMenuItemClickListener ...
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_main, container, false);
...
}
@Override
public int getMenu() {
return R.menu.search;
}
XML 代码:
<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"
tools:context="com.sepandar.xengine.fragment.MainFragment">
<android.support.design.widget.AppBarLayout
android:id="@+id/appBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
android:fitsSystemWindows="true"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsingToolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimaryDark"
app:expandedTitleMarginEnd="64dp"
app:expandedTitleMarginStart="48dp"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<com.sepandar.xengine.views.XTabLayout
android:id="@+id/xTab"
android:layout_width="match_parent"
android:layout_height="200dp"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
app:tabMode="scrollable"/>
<com.api.common.widget.MyToolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@android:color/transparent"
app:layout_collapseMode="pin"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:theme="@style/ToolBarStyle"/>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="@+id/viewPager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/xTab"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
<com.nt.googleplaysearch.views.SearchView
android:id="@+id/search"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="invisible"
app:layout_collapseMode="pin"/>
</android.support.design.widget.CoordinatorLayout>
我希望在折叠时 appBarLayout、gone public int getMenu() 以及在展开时显示此 public int getMenu()。
我该怎么办?
【问题讨论】:
-
你能把你相关的XML文件包含到工具栏和appbar代码中
-
@BhunnuBaba,请看我的更新帖!你能帮帮我吗?
-
一旦尝试使用 appBarLayout 添加OnOffsetChangedListener
-
@BhunnuBaba,你能把代码发给我吗?请
-
@BhunnuBaba,你在这里吗?
标签: android android-view