sho*_*reh 7 size android dialog
我有一个从对话框扩展的自定义Dialog.为了在其上放置组件,我需要知道对话框的宽度.我怎么能这样做?谢谢
编辑:
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;
}
}
Run Code Online (Sandbox Code Playgroud)
mWindowWidth为零.
这会起作用。
@Override
public void onWindowFocusChanged (boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
int height=mDialog.getWindow().getDecorView().getHeight();
int width=mDialog.getWindow().getDecorView().getWidth();
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
5643 次 |
最近记录: |