title: Android - positioning TextView in layout programmatically
body: <p>I don't know how I can set the TextView on the right side in my RelativeLayout. Adding gravity to the TextView didn't work. Thanks for helping me.</p>
  
  <pre><code>    RelativeLayout relativeLayout = new RelativeLayout(context);
      relativeLayout.setGravity(Gravity.CENTER_HORIZONTAL); // center in linearLayout_power_stations_bar
  
      textView = new TextView(context);
      textView.setText(String.valueOf(nuke_count));
      textView.setTextColor(activity.getResources().getColor(R.color.game_powerStationsBar_textOverIcon));
      textView.setTextSize(16);
  
      relativeLayout.addView(textView); // TextView over image
      relativeLayout.addView(imageView); // adding image
  
      linearLayout_power_stations_bar.addView(relativeLayout); // adding to other layout
  </code></pre>