我有一個從對話框擴展的自定義對話框。 爲了放置組件,我需要知道對話框的寬度。我怎麼能這樣做? 感謝如何在android中獲取自定義對話框的大小?
編輯:
public class AnswerTypeDialog extends Dialog{
public AnswerTypeDialog(Context context) {
super(context);
mContext = context;
}
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
init();
}
protected void init(){
ll=(RelativeLayout) LayoutInflater.from(mContext).inflate(R.layout.answertype_layout, null);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(ll);
mWindowWidth = this.getWindow().getAttributes().width;
}
}
mWindowWidth爲零。
它取決於你給對話框的高度寬度。 – AkashG 2012-07-09 09:34:38
@seaplain你知道嗎? – anuj 2014-04-11 17:34:55
試圖改變你的想法。使用資源標識並根據屏幕大小創建多個佈局。 – vladaman 2014-12-14 19:31:47