Я использую настраиваемое всплывающее окно в виде списка, это всплывающее окно нужно нарисовать наполовину через высоту триггера и в левой части триггера.Отобразить всплывающее окно в левом краю окна
Я в состоянии достигнуть первой части, второй кажется неуловимым, вот мой код:
public class QuickAction implements View.OnTouchListener {
private View triggerView;
private PopupWindow window;
protected final WindowManager windowManager;
public QuickAction(View triggerView) {
this.triggerView = triggerView;
window = new PopupWindow(triggerView.getContext());
window.setTouchable(true);
window.setTouchInterceptor(this);
windowManager = (WindowManager) triggerView.getContext().getSystemService(Context.WINDOW_SERVICE);
ImageView imageView = new ImageView(triggerView.getContext());
imageView.setImageResource(R.drawable.ic_action_email);
LayoutInflater layoutInflater = (LayoutInflater) triggerView.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View layout = layoutInflater.inflate(R.layout.quick_action_popup_layout, null, false);
window.setContentView(layout);
// window.setBackgroundDrawable(null);
window.setWidth(WindowManager.LayoutParams.WRAP_CONTENT);
window.setHeight(WindowManager.LayoutParams.WRAP_CONTENT);
window.setTouchable(true);
window.setFocusable(false);
window.setOutsideTouchable(true);
}
public boolean onTouch(View v, MotionEvent event) {
if (MotionEvent.ACTION_OUTSIDE == event.getAction()) {
this.window.dismiss();
return true;
}
return false;
}
public void show() {
int[] location = new int[2];
triggerView.getLocationOnScreen(location);
window.showAtLocation(triggerView, Gravity.NO_GRAVITY, location[0] + (triggerView.getLeft()), location[1] + (triggerView.getHeight()/2));
}
}
То, что я хочу, чтобы выровнять по правому краю моего всплывающего окна с левой EGDE моего triggerview
Triggerview моя кнопка, где я хочу, чтобы создать всплывающее окно, соответствующие части коды существ:
public void show() {
int[] location = new int[2];
triggerView.getLocationOnScreen(location);
window.showAtLocation(triggerView, Gravity.NO_GRAVITY, location[0] + (triggerView.getLeft()), location[1] + (triggerView.getHeight()/2));
}
Однако это Nto дать мне желаемый результат. Есть идеи?