How to add relative Layout below some element dynamically

Tom Wally

Please help me to add a RelativeLayout below a RadioButton dynamically (I have to create RelativeLayout and RadioButton in class).

Something like this:

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >

    <RadioButton
          android:id="@+id/radioButton3"
          android:text="RadioButton" />


    <RelativeLayout
          android:id="@+id/relativeLayout2"
          android:layout_below="@+id/radioButton3"
          android:layout_width="match_parent"
          android:layout_height="wrap_content">

    </RelativeLayout>

</LinearLayout>

To View I can write:

myLayout.addView(myView, layoutParams);

But how about ViewGroup?

Rindt Lin

I am not sure whether I understand u. Please check it and give me feedback. Thank you!

    LinearLayout mLayout = (LinearLayout) findViewById(R.id.myLayout);
    LayoutParams p = new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
    RadioButton mRadioButton = new RadioButton(this);
    mRadioButton.setLayoutParams(p);
    mLayout.addView(mRadioButton);

    p = new LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.WRAP_CONTENT);
    RelativeLayout mRelativeLayout = new RelativeLayout(this);
    mRelativeLayout.setLayoutParams(p);
    mLayout.addView(mRelativeLayout);

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Relative layout: layout_below a CenterVertical element

From Dev

Dynamically add element to layout

From Dev

How to dynamically insert a relative layout into a table layout

From Dev

Dynamically add Layout after some layout?

From Dev

How to center a view in parent and add a view below it inside a Relative Layout inside a Scroll view

From Dev

How to add the layout dynamically

From Dev

how can i add and remove element dynamically from linear layout?

From Dev

Add Buttons to Relative Layout Dynamically or Extended Linear Layout android

From Dev

Add Buttons to Relative Layout Dynamically or Extended Linear Layout android

From Dev

How to add relative layout to relative layout with slide in effect?

From Dev

In a relative layout, how to display the run time textview below another textview?

From Dev

How to add vertical line for below layout?

From Dev

How to add buttons below each other dynamically

From Dev

how to set each layout below another layout inside relative layout in android

From Dev

how to set each layout below another layout inside relative layout in android

From Dev

Add relative layout background

From Dev

Android place Relative Layout below Relative Layout programmatically

From Dev

Android place Relative Layout below Relative Layout programmatically

From Dev

How to dynamically add ImageView to layout using Adapter

From Dev

How to add this type of layout dynamically (android)

From Dev

How to add 2 fragments dynamically in a single layout?

From Dev

Android: Relative layout content goes below screen

From Dev

Place a button in Relative layout below the custom zoomview

From Dev

Relative Layout: How to center view in the remaining space to the right of an element?

From Dev

Android include layout below element

From Dev

how to add a background image to a scrollview with relative layout in android?

From Dev

How do I add button below ListView dynamically

From Dev

Dynamically add layout to another layout

From Dev

Dynamically add QWebEngineView to layout

Related Related

  1. 1

    Relative layout: layout_below a CenterVertical element

  2. 2

    Dynamically add element to layout

  3. 3

    How to dynamically insert a relative layout into a table layout

  4. 4

    Dynamically add Layout after some layout?

  5. 5

    How to center a view in parent and add a view below it inside a Relative Layout inside a Scroll view

  6. 6

    How to add the layout dynamically

  7. 7

    how can i add and remove element dynamically from linear layout?

  8. 8

    Add Buttons to Relative Layout Dynamically or Extended Linear Layout android

  9. 9

    Add Buttons to Relative Layout Dynamically or Extended Linear Layout android

  10. 10

    How to add relative layout to relative layout with slide in effect?

  11. 11

    In a relative layout, how to display the run time textview below another textview?

  12. 12

    How to add vertical line for below layout?

  13. 13

    How to add buttons below each other dynamically

  14. 14

    how to set each layout below another layout inside relative layout in android

  15. 15

    how to set each layout below another layout inside relative layout in android

  16. 16

    Add relative layout background

  17. 17

    Android place Relative Layout below Relative Layout programmatically

  18. 18

    Android place Relative Layout below Relative Layout programmatically

  19. 19

    How to dynamically add ImageView to layout using Adapter

  20. 20

    How to add this type of layout dynamically (android)

  21. 21

    How to add 2 fragments dynamically in a single layout?

  22. 22

    Android: Relative layout content goes below screen

  23. 23

    Place a button in Relative layout below the custom zoomview

  24. 24

    Relative Layout: How to center view in the remaining space to the right of an element?

  25. 25

    Android include layout below element

  26. 26

    how to add a background image to a scrollview with relative layout in android?

  27. 27

    How do I add button below ListView dynamically

  28. 28

    Dynamically add layout to another layout

  29. 29

    Dynamically add QWebEngineView to layout

HotTag

Archive