I am a newbie in Android. I have a requirement where I have to add the imageViews dynamically onto a linear layout and then have to animate each image individually.
I am not aware of the way to add the imageViews dynamically onto a linear layout. Plz help me out.
Thanks
LinearLayout is a view group that aligns all children in a single direction, vertically or horizontally. You can specify the layout direction with the android:orientation attribute.
Go to -> Edit File Templates option. Change the ${ROOT_TAG} to LinearLayout in both of these LayoutResourceFile. xml and LayoutResourceFile_vertical. xml and you will always get LinearLayout as parent for future.
You can add view
dynamically like this.
LinearLayout.LayoutParams imParams =
new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
ImageView imSex = new ImageView(context);
imSex.setImageResource(getmyImage());
mainlayout.addView(imSex,imParams);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With