title: Android: Programmatically set checkbox set text position on the right
body: <p>How can I set a programmatically created checkbox's text to be aligned on the left instead of right side of the checkbox. Below is a code snippet: </p>
  
  <pre><code>Checkbox check1 = new Checkbox(getApplicationContext());
  check1.setLayoutParams(new ActionBar.LayoutParams(LinearLayoutCompat.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT));
  check1.setId(fieldNo);
  check1.setTextColor(Color.BLACK);
  check1.setGravity(Gravity.RIGHT);
  check1.setText(formField.get(fieldNo));
  </code></pre>
  
  <p>The above code resulted in the text shown on the right of the checkbox. </p>
  
  <p>Here is a screenshot : <a href="https://i.stack.imgur.com/ecrm5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ecrm5.png" alt="enter image description here"></a></p>
  
  <p>How can I have the text on the left of the checkbox?</p>