Saturday, February 13, 2016

Android Create Dynamic UI using Java


1:  super.onCreate(savedInstanceState);  
2:  RelativeLayout.LayoutParams layout= new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT);  
3:  layout.addRule(RelativeLayout.CENTER_HORIZONTAL);   // setting Height  
4:  layout.addRule(RelativeLayout.CENTER_VERTICAL);    // Setting Width   
5:  RelativeLayout myLayout = new RelativeLayout(this);  // using this for changing background colormyLayout.setBackgroundColor(Color.GREEN);      // setting background color to green  
6:  Button btn = new Button(this);  
7:  btn.setBackgroundColor(Color.BLUE);         // Defining Btn Background Color to Bluebtn.setText("Touch ME");              // Defining button textbtn.setLayoutParams(layout);  
8:  //ViewPropertyAnimator anim=btn.animate();  
9:  myLayout.addView(btn);  
10:  setContentView(myLayout);  


i hope that it was informative for you and I would like to thank you for reading.

No comments:

Post a Comment