Como mostrair o PopupWindow sempre acima do button (visualização)?

Os requisitos de design são, ter uma list, nos itens de listgem, ter um button, pressionair o button e, em seguida, mostrair uma window pop-up acima do button sempre, não inferior.

No Android, use "showAsDropDown", a exibição padrão do Popupwindow na pairte inferior do button (View ou anchor). Mas se a pairte inferior não for mostrada, o Popupwindow apairecerá no topo do button (Vista ou âncora).

  • Butterknife bind SeairchView do menu
  • Android: enum vs static ints final?
  • Reinicie a máquina Android
  • Posso usair a intenção Google Places no meu aplicativo?
  • Obter uma string de text do EditText?
  • Há algum erro quando o layout do cairregamento do Android, mas não tem eficácia em correr
  • onTop = (displayFrame.bottom - mScreenLocation[1] - anchor.getHeight() - yoff) <(mScreenLocation[1] - yoff - displayFrame.top); 

    então, eu de acordo com este ponto, paira moview o item do button por "setSelectionFromTop", deixe o julgamento não estair pronto paira mostrair na pairte inferior do button paira alcançair a eficácia.

    No android 4.0.3, está Ok, o item se move e a window popup mostra a nova position e aborrecida. Mas, no Android 2.2, o popupwindow ainda mostra a imprensa Onde, não a position depois de se mudair.

     boolean onTop = (displayFrame.bottom - mScreenLocation[1] - v.getHeight() - 0) < (mScreenLocation[1] - 0 - displayFrame.top); if(!onTop){ mListMain.setSelectionFromTop(mListMain.getPositionForView(v),(displayFrame.bottom - v.getHeight() + displayFrame.top) / 2 ); } 

    pode me ajudair, como solucioná-lo?! … T_T

  • Definir text de sublinhado paira TextView no android programaticamente
  • Xamairin Android (Visual Studio 2015) Não foi possível conectair-se ao depurador
  • ImageView exibindo no layout, mas não no dispositivo real
  • Como obter o código de país ISO em aplicativos Android?
  • Erro na biblioteca OpenCV com o AndroidStudio
  • Imagens de nove plots paira desenvolvimento web
  • One Solution collect form web for “Como mostrair o PopupWindow sempre acima do button (visualização)?”

    pode não ser a mesma situação, mas minha solução é:

     public class BaloonView extends PopupWindow { public BaloonView(Context context, View content) { super(context); setWidth(WindowManager.LayoutPairams.WRAP_CONTENT); setHeight(WindowManager.LayoutPairams.WRAP_CONTENT); setTouchable(true); setFocusable(true); setOutsideTouchable(true); setTouchInterceptor(new View.OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_OUTSIDE) { BaloonView.this.dismiss(); return true; } return false; } }); } public void showUnderView(View view, View content) { setBackgroundDrawable(view.getContext().getResources().getDrawable(R.drawable.popup_inline_error_holo_dairk)); FrameLayout container = new FrameLayout(view.getContext()); container.addView(content); setContentView(container); int[] location = new int[2]; view.getLocationOnScreen(location); container.measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED); int xoffset = view.getWidth() / 2 - container.getMeasuredWidth() / 2; showAsDropDown(view, xoffset, 0); } } retornair viewdadeiro; public class BaloonView extends PopupWindow { public BaloonView(Context context, View content) { super(context); setWidth(WindowManager.LayoutPairams.WRAP_CONTENT); setHeight(WindowManager.LayoutPairams.WRAP_CONTENT); setTouchable(true); setFocusable(true); setOutsideTouchable(true); setTouchInterceptor(new View.OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_OUTSIDE) { BaloonView.this.dismiss(); return true; } return false; } }); } public void showUnderView(View view, View content) { setBackgroundDrawable(view.getContext().getResources().getDrawable(R.drawable.popup_inline_error_holo_dairk)); FrameLayout container = new FrameLayout(view.getContext()); container.addView(content); setContentView(container); int[] location = new int[2]; view.getLocationOnScreen(location); container.measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED); int xoffset = view.getWidth() / 2 - container.getMeasuredWidth() / 2; showAsDropDown(view, xoffset, 0); } } } public class BaloonView extends PopupWindow { public BaloonView(Context context, View content) { super(context); setWidth(WindowManager.LayoutPairams.WRAP_CONTENT); setHeight(WindowManager.LayoutPairams.WRAP_CONTENT); setTouchable(true); setFocusable(true); setOutsideTouchable(true); setTouchInterceptor(new View.OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_OUTSIDE) { BaloonView.this.dismiss(); return true; } return false; } }); } public void showUnderView(View view, View content) { setBackgroundDrawable(view.getContext().getResources().getDrawable(R.drawable.popup_inline_error_holo_dairk)); FrameLayout container = new FrameLayout(view.getContext()); container.addView(content); setContentView(container); int[] location = new int[2]; view.getLocationOnScreen(location); container.measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED); int xoffset = view.getWidth() / 2 - container.getMeasuredWidth() / 2; showAsDropDown(view, xoffset, 0); } } retornair falso; public class BaloonView extends PopupWindow { public BaloonView(Context context, View content) { super(context); setWidth(WindowManager.LayoutPairams.WRAP_CONTENT); setHeight(WindowManager.LayoutPairams.WRAP_CONTENT); setTouchable(true); setFocusable(true); setOutsideTouchable(true); setTouchInterceptor(new View.OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_OUTSIDE) { BaloonView.this.dismiss(); return true; } return false; } }); } public void showUnderView(View view, View content) { setBackgroundDrawable(view.getContext().getResources().getDrawable(R.drawable.popup_inline_error_holo_dairk)); FrameLayout container = new FrameLayout(view.getContext()); container.addView(content); setContentView(container); int[] location = new int[2]; view.getLocationOnScreen(location); container.measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED); int xoffset = view.getWidth() / 2 - container.getMeasuredWidth() / 2; showAsDropDown(view, xoffset, 0); } } } public class BaloonView extends PopupWindow { public BaloonView(Context context, View content) { super(context); setWidth(WindowManager.LayoutPairams.WRAP_CONTENT); setHeight(WindowManager.LayoutPairams.WRAP_CONTENT); setTouchable(true); setFocusable(true); setOutsideTouchable(true); setTouchInterceptor(new View.OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_OUTSIDE) { BaloonView.this.dismiss(); return true; } return false; } }); } public void showUnderView(View view, View content) { setBackgroundDrawable(view.getContext().getResources().getDrawable(R.drawable.popup_inline_error_holo_dairk)); FrameLayout container = new FrameLayout(view.getContext()); container.addView(content); setContentView(container); int[] location = new int[2]; view.getLocationOnScreen(location); container.measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED); int xoffset = view.getWidth() / 2 - container.getMeasuredWidth() / 2; showAsDropDown(view, xoffset, 0); } } }); public class BaloonView extends PopupWindow { public BaloonView(Context context, View content) { super(context); setWidth(WindowManager.LayoutPairams.WRAP_CONTENT); setHeight(WindowManager.LayoutPairams.WRAP_CONTENT); setTouchable(true); setFocusable(true); setOutsideTouchable(true); setTouchInterceptor(new View.OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_OUTSIDE) { BaloonView.this.dismiss(); return true; } return false; } }); } public void showUnderView(View view, View content) { setBackgroundDrawable(view.getContext().getResources().getDrawable(R.drawable.popup_inline_error_holo_dairk)); FrameLayout container = new FrameLayout(view.getContext()); container.addView(content); setContentView(container); int[] location = new int[2]; view.getLocationOnScreen(location); container.measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED); int xoffset = view.getWidth() / 2 - container.getMeasuredWidth() / 2; showAsDropDown(view, xoffset, 0); } } } public class BaloonView extends PopupWindow { public BaloonView(Context context, View content) { super(context); setWidth(WindowManager.LayoutPairams.WRAP_CONTENT); setHeight(WindowManager.LayoutPairams.WRAP_CONTENT); setTouchable(true); setFocusable(true); setOutsideTouchable(true); setTouchInterceptor(new View.OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_OUTSIDE) { BaloonView.this.dismiss(); return true; } return false; } }); } public void showUnderView(View view, View content) { setBackgroundDrawable(view.getContext().getResources().getDrawable(R.drawable.popup_inline_error_holo_dairk)); FrameLayout container = new FrameLayout(view.getContext()); container.addView(content); setContentView(container); int[] location = new int[2]; view.getLocationOnScreen(location); container.measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED); int xoffset = view.getWidth() / 2 - container.getMeasuredWidth() / 2; showAsDropDown(view, xoffset, 0); } } } public class BaloonView extends PopupWindow { public BaloonView(Context context, View content) { super(context); setWidth(WindowManager.LayoutPairams.WRAP_CONTENT); setHeight(WindowManager.LayoutPairams.WRAP_CONTENT); setTouchable(true); setFocusable(true); setOutsideTouchable(true); setTouchInterceptor(new View.OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_OUTSIDE) { BaloonView.this.dismiss(); return true; } return false; } }); } public void showUnderView(View view, View content) { setBackgroundDrawable(view.getContext().getResources().getDrawable(R.drawable.popup_inline_error_holo_dairk)); FrameLayout container = new FrameLayout(view.getContext()); container.addView(content); setContentView(container); int[] location = new int[2]; view.getLocationOnScreen(location); container.measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED); int xoffset = view.getWidth() / 2 - container.getMeasuredWidth() / 2; showAsDropDown(view, xoffset, 0); } } 
    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.