Last active
August 29, 2015 14:06
-
-
Save rocboronat/940b43b116c11aa9c52b to your computer and use it in GitHub Desktop.
Show a PopupWindow with negative margin on a MenuItem of the ActionBar
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public boolean onCreateOptionsMenu(Menu menu) { | |
MenuInflater inflater = getMenuInflater(); | |
inflater.inflate(R.menu.menu_listoffers, menu); | |
new Handler().post(new Runnable() { | |
@Override | |
public void run() { | |
final View menuItemView = findViewById(R.id.action_search); | |
View layoutOfPopup = getLayoutInflater().inflate(R.layout.popup_help_search, null); | |
popupMessage = new PopupWindow(layoutOfPopup, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); | |
popupMessage.setContentView(layoutOfPopup); | |
popupMessage.showAsDropDown(menuItemView, -20, -20); //It's friday night, but you mustn't use magic numbers in real code! | |
} | |
}); | |
return super.onCreateOptionsMenu(menu); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment