Position afollestad MaterialDialog below a button

岁酱吖の 提交于 2019-12-12 03:54:40

问题


Is there an option to position https://github.com/afollestad/material-dialogs below a button as like the mock up I have attached .

Or is there any other library to fulfill my requirement.


回答1:


You need to catch the location of the clicked UI that is your Filter icon ImageView. You have to use the

getLocationOnScreen() API and PopUpWindow component.

This is the sample code for inflating the FilterUI

    text_click=(TextView)findViewById(R.id.text_click);

          text_click.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  LayoutInflater inflater= (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                  int[] locationOfView = new int[2];
                  text_click.getLocationOnScreen(locationOfView);
                  final View mView = inflater.inflate(R.layout.activity_map_view, null, false);
                  final PopupWindow popUp = new PopupWindow(mView, 500, 500, false);
                  popUp.setTouchable(true);
                  popUp.setFocusable(true);
                  popUp.setOutsideTouchable(true);
popUp.setBackgroundDrawable(new ColorDrawable(ContextCompat.getColor(mContext,android.R.color.transparent)));
                  popUp.showAtLocation(mView, Gravity.NO_GRAVITY, locationOfView[0], (locationOfView[1]+ text_click.getHeight()));
              }
          });


来源:https://stackoverflow.com/questions/35220043/position-afollestad-materialdialog-below-a-button

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!