Sono arrivato a questo codice che mi mostra tutti gli elementi, ma mi manca di riuscire ad impostare i margini.
codice:
TextView textView1 = new TextView(this);
RelativeLayout.LayoutParams params1 = new RelativeLayout.LayoutParams(
LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT);
textView1.setId(1);
textView1.setText("Stazione1");
layout.addView(textView1,params1);
ImageView imageView1 = new ImageView(this);
imageView1.setImageResource(R.drawable.tstop);
imageView1.setAdjustViewBounds(true);
RelativeLayout.LayoutParams params2 = new RelativeLayout.LayoutParams(
LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT);
params2.addRule(RelativeLayout.BELOW,textView1.getId());
imageView1.setId(2);
layout.addView(imageView1, params2);
TextView textView2 = new TextView(this);
textView2.setId(3);
RelativeLayout.LayoutParams params3 = new RelativeLayout.LayoutParams(
LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT);
params3.addRule(RelativeLayout.BELOW,textView1.getId());
params3.addRule(RelativeLayout.RIGHT_OF,imageView1.getId());
textView2.setText("12:03~12:20");
layout.addView(textView2,params3);
TextView textView3 = new TextView(this);
textView3.setId(4);
RelativeLayout.LayoutParams params4 = new RelativeLayout.LayoutParams(
LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT);
params4.addRule(RelativeLayout.BELOW,textView1.getId());
params4.addRule(RelativeLayout.RIGHT_OF,textView2.getId());
textView3.setText("Nome Linea");
layout.addView(textView3,params4);
Devo impostare un margine di 10dp a sinistra di textView2 e 10dp a sinistra di textImage3