skydoves / PowerMenu

:fire: Powerful and modernized popup menu with fully customizable animations.
Apache License 2.0
1.19k stars 175 forks source link

in recyclerview last items the context menu isn't shown correctly #58

Closed siavash-sajjad closed 3 years ago

siavash-sajjad commented 4 years ago

i use following code for show context menu in every item of recyclerview:

powerMenu = new PowerMenu.Builder(BackupActivity.this) .addItem(new PowerMenuItem("بازگردانی")) .addItem(new PowerMenuItem("ارسال به سرور")) .addItem(new PowerMenuItem("اشتراک گذاری")) //.setAnimation(MenuAnimation.SHOWUP_TOP_RIGHT) .setMenuRadius(10f) // sets the corner radius. .setMenuShadow(10f) // sets the shadow. .setDivider(new ColorDrawable(ContextCompat.getColor(BackupActivity.this, R.color.main_background))) .setDividerHeight(1) .setTextColor(ContextCompat.getColor(BackupActivity.this, R.color.text_color)) .setTextGravity(Gravity.CENTER) .setTextTypeface(ResourcesCompat.getFont(BackupActivity.this, R.font.iy_regular)) .setTextSize(15) .setSelectedTextColor(Color.WHITE) .setMenuColor(Color.WHITE) .setSelectedMenuColor(ContextCompat.getColor(BackupActivity.this, R.color.colorPrimary)) .build();

but in last items the context menu isn't shown correctly like the picture below: pic

i expected, detect item position and show context menu automatically in up or bottom or left or right is it possible?

sorry for poor my english

skydoves commented 4 years ago

Hi, thank you for your issue :) Does it occur the same issue if you give some padding-bottom or margin-bottom to the recyclerView?

siavash-sajjad commented 4 years ago

Hi, thank you for your issue :) Does it occur the same issue if you give some padding-bottom or margin-bottom to the recyclerView?

no, if using clipToPadding and set padding bottom fix this problem, but this method isn't nice in UI

BigCoach commented 4 years ago
  • Library Version: 2.1.2
  • Affected Device(s): Xiaomi MI 9 With Android 10

i use following code for show context menu in every item of recyclerview:

...

Try to use showAsAnchorRightTop with margin to show menu

powerMenu?.showAsAnchorRightTop(
                            view,
                            0,
                            -your menu height
                        )

if your recyclerview item is last visible on the screen. To determine that, you can use:

LinearLayoutManager.findLastVisibleItemPosition()