相关疑难解决方法(0)

如何在android中获取自定义对话框的大小?

我有一个从对话框扩展的自定义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为零.

size android dialog

7
推荐指数
1
解决办法
5643
查看次数

标签 统计

android ×1

dialog ×1

size ×1