Search code examples
androidviewandroid-wrap-content

Is it possible set wrapContent attribute on view without parrent?


I have a simple button view, and set it as content view. Is it possible to resize this view programmaticly to "wrap_content"?

Button button = new Button(getContext());
button.setText("Some text");
setContentView(button);

Solution

  • You can not set LayoutParams for a view without parent.