RelativeLayout relativeLayout = new RelativeLayout(this); relativeLayout.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT)); TextView textView = new TextView(this); textView.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT)); textView.setText("Hello World!"); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 24); textView.setId(View.generateViewId()); ImageView imageView = new ImageView(this); imageView.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT)); imageView.setImageResource(R.drawable.image_one); RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) imageView.getLayoutParams(); params.addRule(RelativeLayout.BELOW, textView.getId()); params.addRule(RelativeLayout.ALIGN_PARENT_END); relativeLayout.addView(textView); relativeLayout.addView(imageView); setContentView(relativeLayout);In this example, we have created a RelativeLayout dynamically in Java code and added two child views, a TextView and an ImageView. The TextView is centered in the parent layout using the `setLayoutParams` method and the `generateViewId` method is used to generate a unique ID for the view. The ImageView is positioned below the TextView using the `addRule` method and aligned to the end of the parent using the same method. The package library for java android.widget RelativeLayout is android.widget.