0
How do I add a ImageView
at run time to LinearLayout
or even a TableLayout
?
0
How do I add a ImageView
at run time to LinearLayout
or even a TableLayout
?
1
Both LinearLayout
and TableLayout
inherit from ViewGroup
. The ViewGroup
is the class that has the ability to aggregate and compose the hierarchy of View's
.
In the case of LinearLayout
just call addView
passing his ImageView
. It is optional to pass an index or a LayoutParams
, you will be in charge of the situation.
In the case of TableLayout
you will need to encompass your ImageView
in a TableRow
before and add the TableRow
at the TableLayout
.
One recommendation I give is to check the rules of layout_width
and layout_height
to use in LayoutParams
of ImageView
and/or the TableRow
.
In the case of LinearLayout
check the orientation to avoid problems.
Browser other questions tagged java android-layout
You are not signed in. Login or sign up in order to post.
great, that’s what I needed... obg.
– Herik R
@Herikr, if the answer helped you, mark it as right, so as not to confuse members thinking the answer is not useful.
– Wakim
It says that I need 15 points to vote in favour.
– Herik R
@Herik, just click on the green "arrow", indicating that this is the correct answer.
– Wakim