How to set setLayoutParams() for LinearLayout elements. in MainActivity.java. I wrote the following code for set Layout params and
Try this in onCreate at the beginning of your activity (should replace the pic though). Don't forget to comment the setContentView that comes by default:
// setContentView(R.layout.activity_main);
TextView label = new TextView(this);
label.setText("This is working, congrats!");
label.setTextSize(20);
label.setGravity(Gravity.CENTER_HORIZONTAL);
LinearLayout ll = new LinearLayout(this);
ll.setOrientation(LinearLayout.VERTICAL);
ll.setLayoutParams(new WindowManager.LayoutParams());
ll.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT));
ll.setGravity(Gravity.CENTER);
ll.addView(label);
setContentView(ll);