将afollestad MaterialDialog放置在按钮下方 [英] Position afollestad MaterialDialog below a button
本文介绍了将afollestad MaterialDialog放置在按钮下方的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以定位 https://github.com/afollestad/material-dialogs在按钮下方,就像我附加的模型一样.
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.
推荐答案
您需要捕获单击的UI的位置,该位置是您的过滤器图标 ImageView
.您必须使用
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.
这是用于扩展FilterUI的示例代码
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()));
}
});
这篇关于将afollestad MaterialDialog放置在按钮下方的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文