I am creating an activity that as a dialog format: it does not cover the whole screen, but only part of it. What I did was in the onCreate() method of this activity, after calling setContentView(), I call:
window.setLayout(windowWidthInDp, LayoutParams.WRAP_CONTENT);
And it does not work. I need to do the following instead to make it work:
window.getDecorView().post(new Runnable() {
@Override
public void run() {
window.setLayout(windowWidthInDp, LayoutParams.WRAP_CONTENT);
}
});
Again, this is AFTER setContentView() is called. Why do I have to pose it into the message queue instead of calling it directly? Thanks!