List of usage examples for android.widget PopupWindow setAnimationStyle
public void setAnimationStyle(int animationStyle)
Change the animation style resource for this popup.
If the popup is showing, calling this method will take effect only the next time the popup is shown or through a manual call to one of the #update() methods.
From source file:com.kccomy.orgar.ui.note.NoteFragment.java
private void initPopupWindow() { View popupWindowView = getActivity().getLayoutInflater().inflate(R.layout.popup_window_share, null); //??//from www .java 2 s. c o m Intent shareIntent = new Intent(Intent.ACTION_SEND); shareIntent.addCategory(Intent.CATEGORY_DEFAULT); shareIntent.setType("text/plain"); PackageManager packageManager = getContext().getPackageManager(); List<ResolveInfo> resolveInfos = packageManager.queryIntentActivities(shareIntent, PackageManager.GET_RESOLVED_FILTER); // RecyclerAdapter RecyclerView recyclerView = (RecyclerView) popupWindowView.findViewById(R.id.popup_widow_share_recycler); ShareAdapter shareAdapter = new ShareAdapter(packageManager); shareAdapter.setData(resolveInfos); shareAdapter.setAppIconClickListener(shareListener); recyclerView.setAdapter(shareAdapter); recyclerView .setLayoutManager(new GridLayoutManager(getContext(), 2, LinearLayoutManager.HORIZONTAL, false)); // ?PopupWindow popupWindowView.setFocusable(true); popupWindowView.setFocusableInTouchMode(true); PopupWindow popupWindow = new PopupWindow(popupWindowView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); popupWindow.setFocusable(true); popupWindow.setOutsideTouchable(true); popupWindow.setBackgroundDrawable(new ColorDrawable(0x00000000)); popupWindow.setAnimationStyle(R.style.anim_menu_bottombar); setWindowAlpha(0.5f); popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() { @Override public void onDismiss() { setWindowAlpha(1f); } }); popupWindow.showAtLocation(getActivity().getLayoutInflater().inflate(R.layout.fragment_note, null), Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, 0); }
From source file:ac.robinson.mediaphone.activity.NarrativeBrowserActivity.java
private void showPopup() { if (mScrollState != AbsListView.OnScrollListener.SCROLL_STATE_FLING) { return;// ww w .j a v a 2 s.c o m } if (mPopup == null) { PopupWindow p = new PopupWindow(this); p.setFocusable(false); p.setContentView(mPopupPosition); p.setWidth(ViewGroup.LayoutParams.MATCH_PARENT); p.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT); p.setBackgroundDrawable(null); p.setAnimationStyle(android.R.style.Animation_Dialog); mPopup = p; } if (mNarratives.getWindowVisibility() == View.VISIBLE) { mPopup.showAtLocation(mNarratives, Gravity.CENTER, 0, 0); } }
From source file:com.luke.lukef.lukeapp.fragments.MapViewFragment.java
/** * Handles showing the Calendar pop up, fetching the selected date, calling to fetch * submissions again/*from w w w . j a va 2 s .c o m*/ */ private void showCalendarPicker() { // Inflate the popup_layout.xml ConstraintLayout viewGroup = (ConstraintLayout) getMainActivity().findViewById(R.id.popup_calendar_root); LayoutInflater layoutInflater = (LayoutInflater) getMainActivity() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); final View layout = layoutInflater.inflate(R.layout.popup_calendar, viewGroup); // Some offset to align the popup a bit to the right, and a bit down, relative to button's position. //or if popup is on edge display it to the left of the circle Display display = getMainActivity().getWindowManager().getDefaultDisplay(); Point size = new Point(0, 0); display.getSize(size); int OFFSET_X = 25; int OFFSET_Y = 25; final DatePicker dP = (DatePicker) layout.findViewById(R.id.popup_calendar_datepicker); // Creating the PopupWindow final PopupWindow popup = new PopupWindow(getMainActivity()); popup.setAnimationStyle(android.R.style.Animation_Dialog); popup.setContentView(layout); popup.setWidth(ViewGroup.LayoutParams.WRAP_CONTENT); popup.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT); popup.setFocusable(true); //gets rid of default background popup.setBackgroundDrawable(new BitmapDrawable(getMainActivity().getResources(), (Bitmap) null)); //popup.setBackgroundDrawable(new BitmapDrawable(getMainActivity().getResources(), (Bitmap) nu)); // Displaying the popup at the specified location, + offsets. popup.showAtLocation(layout, Gravity.NO_GRAVITY, 200 + OFFSET_X, 300 + OFFSET_Y); Calendar minDate; minDate = Calendar.getInstance(); this.tempY = minDate.get(Calendar.YEAR); this.tempM = minDate.get(Calendar.MONTH); this.tempD = minDate.get(Calendar.DAY_OF_MONTH); dP.init(minDate.get(Calendar.YEAR), minDate.get(Calendar.MONTH), minDate.get(Calendar.DAY_OF_MONTH), new DatePicker.OnDateChangedListener() { @Override // Months start from 0, so January is month 0 public void onDateChanged(DatePicker view, int year, int monthOfYear, int dayOfMonth) { tempY = year; tempM = monthOfYear; tempD = dayOfMonth; Log.e(TAG, "onDateChanged: selected " + tempD + " " + tempM + " " + tempY); } }); ImageButton okButton = (ImageButton) layout.findViewById(R.id.popup_calendar_accept); ImageButton cancelButton = (ImageButton) layout.findViewById(R.id.popup_calendar_cancel); okButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Calendar calendar = Calendar.getInstance(); calendar.set(tempY, tempM, tempD, 1, 0); Log.e(TAG, "onClick: calendar time in ms " + calendar.getTimeInMillis()); // clear items from clustermanager and submissionMarkerList, as all new submissions // need to be fetched based on the selected date clusterManager.clearItems(); submissionMarkerIdList.clear(); addAdminMarkersToMap(); setMinDateInMs(calendar.getTimeInMillis()); popup.dismiss(); } }); cancelButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { setMinDateInMs(0); popup.dismiss(); } }); }
From source file:com.bf.zxd.zhuangxudai.my.fragment.FinancialApplyFragment.java
private void ChangeIcon() { //PopupWindow----START-----??PopupWindowPopupWindow??? backgroundAlpha(0.3f);// w ww . j a v a 2s. c o m View view = LayoutInflater.from(getActivity().getBaseContext()).inflate(R.layout.popu_window, null); final PopupWindow popupWindow = new PopupWindow(view, ActionBar.LayoutParams.WRAP_CONTENT, ActionBar.LayoutParams.WRAP_CONTENT, true); popupWindow.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); popupWindow.setOutsideTouchable(true); popupWindow.setFocusable(true); //?? DisplayMetrics dm = new DisplayMetrics(); getActivity().getWindowManager().getDefaultDisplay().getMetrics(dm); popupWindow.setWidth(dm.widthPixels); popupWindow.setAnimationStyle(R.style.popuwindow); //? popupWindow.showAtLocation(view, Gravity.BOTTOM, 0, 0); popupWindow.setOnDismissListener(new poponDismissListener_FinancialApplyFragment()); //PopupWindow-----END //PopupWindow Button button = (Button) view.findViewById(R.id.take_photo);//?? Button button1 = (Button) view.findViewById(R.id.all_photo);//? Button button2 = (Button) view.findViewById(R.id.out);//? button2.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { backgroundAlpha(1f); popupWindow.dismiss(); } }); button1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { backgroundAlpha(1f); popupWindow.dismiss(); //,? allPhoto(); } }); button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { backgroundAlpha(1f); popupWindow.dismiss(); //,Intent???? Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); //,?? File file = FileUitlity.getInstance(getActivity().getApplicationContext()).makeDir("head_image"); //?? path = file.getParent() + File.separatorChar + System.currentTimeMillis() + ".jpg"; //?IntentIntent? intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File(path))); //? intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1); //?Intent??RoundImageView startActivityForResult(intent, REQUEST_CODE); } }); }
From source file:com.bf.zxd.zhuangxudai.my.fragment.CompanyApplyFragment.java
private void ChangeIcon() { //PopupWindow----START-----??PopupWindowPopupWindow??? backgroundAlpha(0.3f);//from w w w. java 2 s. com View view = LayoutInflater.from(getActivity().getBaseContext()).inflate(R.layout.popu_window, null); final PopupWindow popupWindow = new PopupWindow(view, ActionBar.LayoutParams.WRAP_CONTENT, ActionBar.LayoutParams.WRAP_CONTENT, true); popupWindow.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); popupWindow.setOutsideTouchable(true); popupWindow.setFocusable(true); //?? DisplayMetrics dm = new DisplayMetrics(); getActivity().getWindowManager().getDefaultDisplay().getMetrics(dm); popupWindow.setWidth(dm.widthPixels); popupWindow.setAnimationStyle(R.style.popuwindow); //? popupWindow.showAtLocation(view, Gravity.BOTTOM, 0, 0); popupWindow.setOnDismissListener(new poponDismissListener_CompanyApplyFragment()); //PopupWindow-----END //PopupWindow Button button = (Button) view.findViewById(R.id.take_photo);//?? Button button1 = (Button) view.findViewById(R.id.all_photo);//? Button button2 = (Button) view.findViewById(R.id.out);//? button2.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { backgroundAlpha(1f); popupWindow.dismiss(); } }); button1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { backgroundAlpha(1f); popupWindow.dismiss(); //,? Log.i("Daniel", "------"); allPhoto(); } }); button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { backgroundAlpha(1f); popupWindow.dismiss(); //,Intent???? Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); //,?? File file = FileUitlity.getInstance(getActivity().getApplicationContext()).makeDir("head_image"); //?? path = file.getParent() + File.separatorChar + System.currentTimeMillis() + ".jpg"; //?IntentIntent? intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File(path))); //? intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1); //?Intent??RoundImageView startActivityForResult(intent, REQUEST_CODE); } }); }
From source file:cn.zhangls.android.weibo.ui.weibo.WeiboFrameProvider.java
/** * ????//from ww w .j a v a 2 s. c om * * @param holder * @param status */ private void setupPopupBar(final FrameHolder holder, final Status status) { LayoutInflater layoutInflater = LayoutInflater .from(holder.binding.fgHomeWeiboPopupBar.getContext().getApplicationContext()); // final View popupView; if (status.isFavorited() && status.getUser().isFollowing()) {// ?? popupView = layoutInflater.inflate(R.layout.popup_window_weibo_follow_save_post, holder.binding.flWeiboContainer, false); } else if (!status.isFavorited() && status.getUser().isFollowing()) {// ?? popupView = layoutInflater.inflate(R.layout.popup_window_weibo_follow_unsave_post, holder.binding.flWeiboContainer, false); } else if (status.isFavorited() && !status.getUser().isFollowing()) {// ?? popupView = layoutInflater.inflate(R.layout.popup_window_weibo_unfollow_save_post, holder.binding.flWeiboContainer, false); } else {// ?? popupView = layoutInflater.inflate(R.layout.popup_window_weibo_unfollow_unsave_post, holder.binding.flWeiboContainer, false); } // PopupWindow final PopupWindow popupWindow = new PopupWindow(popupView, LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); popupWindow.setTouchable(true); popupWindow.setFocusable(true); popupWindow.setOutsideTouchable(true); // popupWindow popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() { @Override public void onDismiss() { Animation animation = AnimationUtils.loadAnimation( holder.binding.fgHomeWeiboPopupBar.getContext().getApplicationContext(), R.anim.rotate_180_end); animation.setDuration(300); animation.setFillAfter(true); holder.binding.fgHomeWeiboPopupBar.startAnimation(animation); } }); popupWindow.setAnimationStyle(R.style.PopupWindowAnimStyle); // popupWindow Item ? if (status.isFavorited()) {// ?????? popupWindow.getContentView().findViewById(R.id.menu_item_weibo_more_save_post) .setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { FavoritesAPI favoritesAPI = new FavoritesAPI( mBinding.getRoot().getContext().getApplicationContext(), AccessTokenKeeper.readAccessToken( mBinding.getRoot().getContext().getApplicationContext())); BaseObserver<Favorite> observer = new BaseObserver<Favorite>( mBinding.getRoot().getContext().getApplicationContext()) { @Override public void onNext(Favorite value) { } @Override public void onError(Throwable e) { super.onError(e); } @Override public void onComplete() { } }; favoritesAPI.destroy(observer, status.getId()); popupWindow.dismiss(); } }); } else { popupWindow.getContentView().findViewById(R.id.menu_item_weibo_more_unsave_post) .setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { FavoritesAPI favoritesAPI = new FavoritesAPI( mBinding.getRoot().getContext().getApplicationContext(), AccessTokenKeeper.readAccessToken( mBinding.getRoot().getContext().getApplicationContext())); BaseObserver<Favorite> observer = new BaseObserver<Favorite>( mBinding.getRoot().getContext().getApplicationContext()) { @Override public void onNext(Favorite value) { } @Override public void onError(Throwable e) { super.onError(e); } @Override public void onComplete() { } }; favoritesAPI.create(observer, status.getId()); popupWindow.dismiss(); } }); } if (status.getUser().isFollowing()) {// ???? popupWindow.getContentView().findViewById(R.id.menu_item_weibo_more_follow) .setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { popupWindow.dismiss(); } }); } else { popupWindow.getContentView().findViewById(R.id.menu_item_weibo_more_unfollow) .setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { popupWindow.dismiss(); } }); } // ??? holder.binding.fgHomeWeiboPopupBar.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (popupWindow != null && !popupWindow.isShowing()) { Animation animation = AnimationUtils.loadAnimation( holder.binding.fgHomeWeiboPopupBar.getContext().getApplicationContext(), R.anim.rotate_180_start); animation.setDuration(300); animation.setFillAfter(true); holder.binding.fgHomeWeiboPopupBar.startAnimation(animation); popupWindow.showAsDropDown(holder.binding.fgHomeWeiboPopupBar); } } }); }
From source file:com.example.angel.parkpanda.MainActivity.java
@Override public boolean onNavigationItemSelected(MenuItem item) { int id = item.getItemId(); showhideFootWindow(0);/*from w ww . j a v a 2 s. c o m*/ if (id == R.id.nav_menu_findparking) { Intent intent = new Intent(getApplicationContext(), Find_Park.class); startActivityForResult(intent, 2);// Activity is started with requestCode 2 // finish(); } if (id == R.id.nav_menu_account) { initViewSetting(false); if (LOGININFO.flag == 10) { Fragment fragment = new my_account(); FragmentManager fragmentManager = getSupportFragmentManager(); FragmentTransaction FT = fragmentManager.beginTransaction(); FT.setCustomAnimations(R.anim.enter_from_right, R.anim.exit_to_left); FT.replace(R.id.flContent, fragment).commit(); } else { Fragment fragment = new log_in(); FragmentManager fragmentManager = getSupportFragmentManager(); FragmentTransaction FT = fragmentManager.beginTransaction(); FT.setCustomAnimations(R.anim.enter_from_right, R.anim.exit_to_left); FT.replace(R.id.flContent, fragment).commit(); } } if (id == R.id.nav_menu_help) { int currentapiVersion = android.os.Build.VERSION.SDK_INT; if (currentapiVersion > 21) { showhideFootWindow(0); initViewSetting(true); LayoutInflater inflater = (LayoutInflater) getSystemService(Activity.LAYOUT_INFLATER_SERVICE); View layout = inflater.inflate(R.layout.ly_my_help, null); layout.setAnimation(AnimationUtils.loadAnimation(this, R.anim.popupanim)); PopupWindow optionspu = new PopupWindow(layout, DrawerLayout.LayoutParams.WRAP_CONTENT, DrawerLayout.LayoutParams.WRAP_CONTENT); optionspu.setFocusable(true); optionspu.showAtLocation(layout, Gravity.CENTER, 0, 0); optionspu.update(0, 0, DrawerLayout.LayoutParams.WRAP_CONTENT, DrawerLayout.LayoutParams.WRAP_CONTENT); optionspu.setAnimationStyle(R.anim.popupanim); } else { // initViewSetting(false); /* Fragment fragment = new help_dialog(); FragmentManager fragmentManager = getSupportFragmentManager(); FragmentTransaction FT = fragmentManager.beginTransaction(); FT.setCustomAnimations(R.anim.enter_from_right, R.anim.exit_to_left); FT.replace(R.id.flContent, fragment).commit();*/ LayoutInflater layoutInflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE); View popupView = layoutInflater.inflate(R.layout.fragment_help_dialog, null); final PopupWindow optionspu = new PopupWindow(popupView, DrawerLayout.LayoutParams.WRAP_CONTENT, DrawerLayout.LayoutParams.WRAP_CONTENT); optionspu.setFocusable(true); optionspu.showAtLocation(popupView, Gravity.CENTER, 0, 0); Button btnDismiss = (Button) popupView.findViewById(R.id.btn_help_close); btnDismiss.setOnClickListener(new Button.OnClickListener() { @Override public void onClick(View v) { // Toast.makeText(getApplicationContext(), "dsdsa", Toast.LENGTH_SHORT).show(); optionspu.dismiss(); plotMarkers(mMyMarkersArray); initViewSetting(true); } }); } } drawer.closeDrawer(GravityCompat.START); return true; }
From source file:org.medcare.Dicom.DicomActivity.java
private void showPopup(View parent, int gravity, int x, int y, int width, int height) { Log.e("DicomActivity", "showPopup width = " + width + " height " + height); if (DicomActivity.this.mPopup == null) { PopupWindow p = new PopupWindow(this); p.setFocusable(false);//from w w w . j a va2 s . co m p.setContentView(mPopupView); p.setWidth(width); p.setHeight(height); p.setBackgroundDrawable(null); p.setAnimationStyle(R.style.PopupAnimation); DicomActivity.this.mPopup = p; } else { DicomActivity.this.mPopup.setWidth(width); DicomActivity.this.mPopup.setHeight(height); } // coords = myImageController.getCoordinates(); // hitTestRecr.offset(coords.getX(), coords.getY()); DicomActivity.this.mPopup.showAtLocation(parent, gravity, x, y); }
From source file:com.cognizant.trumobi.PersonaLauncher.java
public void showPreviews(final View anchor, int start, int end) { if (mWorkspace != null && mWorkspace.getChildCount() > 0) { if (newPreviews) { showingPreviews = true;/*from ww w . j a v a2s.c om*/ hideDesktop(true); mWorkspace.lock(); mWorkspace.openSense(true); } else { // check first if it's already open final PopupWindow window = (PopupWindow) anchor.getTag(R.id.TAG_PREVIEW); if (window != null) return; Resources resources = getResources(); PersonaWorkspace personaWorkspace = mWorkspace; PersonaCellLayout cell = ((PersonaCellLayout) personaWorkspace.getChildAt(start)); float max; ViewGroup preview; max = personaWorkspace.getChildCount(); preview = new LinearLayout(this); Rect r = new Rect(); // ADW: seems sometimes this throws an out of memory error.... // so... try { resources.getDrawable(R.drawable.pr_preview_background).getPadding(r); } catch (OutOfMemoryError e) { } int extraW = (int) ((r.left + r.right) * max); int extraH = r.top + r.bottom; int aW = cell.getWidth() - extraW; float w = aW / max; int width = cell.getWidth(); int height = cell.getHeight(); // width -= (x + cell.getRightPadding()); // height -= (y + cell.getBottomPadding()); if (width != 0 && height != 0) { showingPreviews = true; float scale = w / width; int count = end - start; final float sWidth = width * scale; float sHeight = height * scale; PreviewTouchHandler handler = new PreviewTouchHandler(anchor); ArrayList<Bitmap> bitmaps = new ArrayList<Bitmap>(count); for (int i = start; i < end; i++) { ImageView image = new ImageView(this); cell = (PersonaCellLayout) personaWorkspace.getChildAt(i); Bitmap bitmap = Bitmap.createBitmap((int) sWidth, (int) sHeight, Bitmap.Config.ARGB_8888); cell.setDrawingCacheEnabled(false); Canvas c = new Canvas(bitmap); c.scale(scale, scale); c.translate(-cell.getLeftPadding(), -cell.getTopPadding()); cell.dispatchDraw(c); image.setBackgroundDrawable(resources.getDrawable(R.drawable.pr_preview_background)); image.setImageBitmap(bitmap); image.setTag(i); image.setOnClickListener(handler); image.setOnFocusChangeListener(handler); image.setFocusable(true); if (i == mWorkspace.getCurrentScreen()) image.requestFocus(); preview.addView(image, LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); bitmaps.add(bitmap); } PopupWindow p = new PopupWindow(this); p.setContentView(preview); p.setWidth((int) (sWidth * count + extraW)); p.setHeight((int) (sHeight + extraH)); p.setAnimationStyle(R.style.AnimationPreview); p.setOutsideTouchable(true); p.setFocusable(true); p.setBackgroundDrawable(new ColorDrawable(0)); p.showAsDropDown(anchor, 0, 0); p.setOnDismissListener(new PopupWindow.OnDismissListener() { public void onDismiss() { dismissPreview(anchor); } }); anchor.setTag(R.id.TAG_PREVIEW, p); anchor.setTag(R.id.workspace, preview); anchor.setTag(R.id.icon, bitmaps); } } } }