layout = new LinearLayout(this); addContentView(layout, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); Button btn =
orientation of your linear layout must be horizontal. change it to vertical