7
我想在popupwindow上设置左右边距。我尝试在layout
上设置布局参数,然后设置边距,但不起作用。android:在PopupWindow上通过代码设置边距
谁能给我代码,以便在popupwindow
设置保证金这里是代码
LayoutInflater inflater = (LayoutInflater) QuestionsActiviy.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View layout = inflater.inflate(R.layout.popup, (ViewGroup) findViewById(R.id.popup_element));
ratePw = new PopupWindow(layout);
ratePw.setWidth(WindowManager.LayoutParams.FILL_PARENT);
ratePw.setHeight(WindowManager.LayoutParams.WRAP_CONTENT);
ratePw.setFocusable(true);
ratePw.showAtLocation(layout, Gravity.CENTER, 0, 0);
感谢。
ratePw不支持addView – Jovan 2012-03-02 12:37:11
试试这个:'RatePw.update(int Left_Margin,int Top_Margin,int Width,int Height);'调整宽度以使其可以工作 – 2012-03-04 05:56:22
我们无法给popupwindow布局参数。这不工作。我尝试了jeet的上述解决方案,并且像魅力一样工作(虽然只有很少的调整)。 – 2015-11-12 19:31:24