i want to create a linear layout where inside it it has text view and image button. And i want to create it dynamically.
1 Answer
LinearLayout layoutSection = new LinearLayout(getActivity());
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.MATCH_PARENT);
params.gravity = Gravity.CENTER;
params.setMargins(5,5,5,5);
imageView.setImageResource(R.drawable.image);
imageView.setLayoutParams(params);
TextView textView = newTextView(getActivity());
TextView.setText(("Enter text here");
layoutSection.addView(textView);
layoutSection.addView(imageView);
2 Comments
user3439710
Thank you it worked. But how can i change the orientation of the linear layout?
srbyk1990
check this link stackoverflow.com/questions/6661261/…