Saiteja Prasadam Saiteja Prasadam - 3 months ago 50
Android Question

Popup menu goes out of the screen

Popup menu on inflate goes out of the screen for this activity, works fine for other

enter image description here

Extending custom AppCompatActivity

Styles:

<style name="AppTheme.ActionBar.TransparentContextTranscition" parent="AppTheme.NoActionBar">
<item name="android:windowActivityTransitions">true</item>
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowContentTransitions">true</item>
<item name="android:windowLightStatusBar">true</item>

<item name="android:itemBackground">@android:color/white</item>
<item name="android:textColor">@android:color/black</item>
<item name="drawerArrowStyle">@style/DrawerArrowStyle</item>
<item name="android:popupMenuStyle">@style/PopupMenu</item>
</style>

<style name="DrawerArrowStyle" parent="Widget.AppCompat.DrawerArrowToggle">
<item name="color">@android:color/white</item>
</style>

<style name="PopupMenu" parent="@android:style/Widget.PopupMenu">
<item name="android:popupBackground">@android:color/white</item>
</style>


Java code

holder.contextMenuView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final PopupMenu popup = new PopupMenu(v.getContext(), v);
popup.inflate(R.menu.song_item_menu_album_inner_layout);
}
});


Toolbar inflate menu works fine

enter image description here

Answer

Looks like I was using

getWindow().setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);

my bad. FLAG_LAYOUT_NO_LIMITS, removes limits for the context menu. (That's the reason, the context menu going out of the screen), Hope that helps for someone