Set Daynamic layout in Android

  Xml File 

  <LinearLayout
                        android:id="@+id/Someonelese"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"     
                        android:layout_below="@+id/viewStub1"
                        android:layout_marginLeft="17dp"
                        android:layout_marginTop="25dp"
                 
                        android:orientation="vertical" >

                        <TextView
                            style="@style/BlackHeadingText"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_weight="2"
                            android:text="Who will be seeing the Doctor?" />

 </LinearLayout>
          
 .Java File          

RelativeLayout.LayoutParams params = null;

rgSomeoneElse = rootView.findViewById(R.id.Someonelese);               
                Log.d("Someoneelse",rgSomeoneElse.toString());           
                params2 = new LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.WRAP_CONTENT);
                params2.addRule(RelativeLayout.BELOW, R.id.viewStub1);                           
                params2.setMargins(15, 40, 15, 0);
                rgSomeoneElse.setLayoutParams(params2);

Comments

Popular posts from this blog

Validate Mobile Number with 10 Digits in ASP.Net