Skip to content

Instantly share code, notes, and snippets.

@nguyenlinhnttu
Created January 2, 2018 06:27
Show Gist options
  • Save nguyenlinhnttu/959a3438b9a5b34e0472fe9ae1f41ee5 to your computer and use it in GitHub Desktop.
Save nguyenlinhnttu/959a3438b9a5b34e0472fe9ae1f41ee5 to your computer and use it in GitHub Desktop.
Popup tip below view android
int[] locScreen = new int[2];
btnActionMenu.getLocationOnScreen(locScreen);
LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View root = inflater.inflate(R.layout.layout_tip_calendar, null);
RelativeLayout rlContent = root.findViewById(R.id.rl_content_tip);
GradientDrawable drawable = (GradientDrawable) rlContent.getBackground();
drawable.setStroke(3, ThemeUtils.getColor(getActivity(), R.attr.colorMainTheme));
PopupWindow popupWindow = new PopupWindow(root, LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT, true);
popupWindow.setBackgroundDrawable(new ColorDrawable(Color.RED));
popupWindow.setOutsideTouchable(true);
popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
@Override
public void onDismiss() {
btnActionMenu.setImageResource(ThemeUtils.getValueAttribute(getActivity(), R.attr.iconQues));
}
});
popupWindow.showAtLocation(btnActionMenu, Gravity.NO_GRAVITY, locScreen[0] + Utils.convertDpToPixel(20), locScreen[1] + Utils.convertDpToPixel(50));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment