I implement Collapsing ToolBar Layout in my Activity. I create RecyclerView too in this Activity. I Have problem, When I how PopUp Menu item RecyclerView, Collapsing ToolBar always Colapse.
This my 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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="com.ad.kostrad.mp.activity.GambarLokasiActvity">
<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
app:elevation="0dp"
app:theme="@style/AppTheme.AppBarOverlay">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<include
layout="@layout/header_item_lokasi" />
<include layout="@layout/custom_toolbar"/>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<include layout="@layout/content_gambar_lokasi_actvity" />
</android.support.design.widget.CoordinatorLayout>
So how to fix it ?
Using
PopupMenu popup = new PopupMenu(activity, v, Gravity.RIGHT);
does not help if you tap items close to the bottom of the screen. It will still try to perform a scroll up to fit the menu.
Actually there seems to be a bug in the support libraries. For a complete fix you can replace for now:
import android.support.v7.widget.PopupMenu;
with
import android.widget.PopupMenu;
as suggested for a similar question. The popupmenu will work as expected.
I Solve this with replace :
PopupMenu popup = new PopupMenu(activity, v);
to
PopupMenu popup = new PopupMenu(activity, v, Gravity.RIGHT);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With