设置dialog样式的activity宽度充满父布局
- 注意 以下代码全部在setContentView之后调用
第一种方法:
getWindow().setLayout(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)
第二种方法:
WindowManager m = getWindowManager()
Display d = m.getDefaultDisplay()
android.view.WindowManager.LayoutParams p =
getWindow().getAttributes()
p.width = d.getWidth()
getWindow().setAttributes(p)
|