I want to add a line of texts inside linear layout(Vertical)
and I want to add them in function in java
How to do this?
Do it like this :
LinearLayout linearLayout = new LinearLayout(this);
linearLayout.setOrientation(LinearLayout.VERTICAL);
//add layout params
LinearLayout.LayoutParams p = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.WRAP_CONTENT);
//add TextView inside the vertical LinearLayout
TextView textView = new TextView(this);
textView.setTextSize(16); //set the text size here
textView.setTextColor(Color.BLACK); // set the text color here
textView.setText("Texts"); // set the text here
textView.setTypeface(Typeface.BOLD); // set the text style here
linearLayout.addView(textView, p); // add the TextView to the LinearLayout
You can add any views inside the LinearLayout as much as you need.
TextViewinside aLinearLayoutprogrammatically?