Note that there are some explanatory texts on larger screens.

plurals
  1. POdynamically adding two views one below other
    primarykey
    data
    text
    <p>I want to add two views one after the other, I used this way but I am getting an error. This is my XML.</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" &gt; &lt;ScrollView android:layout_width="fill_parent" android:layout_height="fill_parent" &gt; &lt;RelativeLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:id="@+id/parent" &gt; &lt;RelativeLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/rel1" android:layout_alignParentTop="true" &gt;&lt;/RelativeLayout&gt; &lt;RelativeLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/rel2" android:layout_below="@+id/rel1" &gt;&lt;/RelativeLayout&gt; &lt;/RelativeLayout&gt; &lt;/ScrollView&gt; &lt;/RelativeLayout&gt; </code></pre> <p>In the two Relative layouts rel1,and rel2 I will add my custom views which are going to be drawn dynamically.</p> <p>my code:</p> <pre><code>setContentView(R.layout.main); RelativeLayout rlstat1=(RelativeLayout)findViewById(R.id.rel1); RelativeLayout rlstat2=(RelativeLayout)findViewById(R.id.rel2); RelativeLayout.LayoutParams para1 = new RelativeLayout.LayoutParams( viewWidth, viewHeight); RelativeLayout.LayoutParams para2 = new RelativeLayout.LayoutParams( viewWidth, viewHeight); rlstat1.setLayoutParams(para1); rlstat1.addView(mView); para2.addRule(RelativeLayout.BELOW, R.id.rel1); rlstat2.addView(mView2); </code></pre> <p>Here mView and mView2 are two view type which I want to set in the two relative layouts. ViewWidth and ViewHeight are the width and height of the screen it is running.</p> <p>The problem: If only one view is added i.e. mView or mView2 it's showing but if both the views are added(like in above) then only one relative layout is shown. I want that both of my views get set one below other.<br> Hope I am clear in my question.Can you please tell me the appropriate way to do this.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload