title: Align dynamically created RelativeLayout to right inside LinearLayout Class
body: <p>I have a LinearLayout class in which I have:
  TexView | ImageView | EditText | ImageView. 
  I want to align the last ImageView all the way to the right side of the LinearLayout its wrapped in. Right now its just placed right after the EditText and not right aligned.  The LinearLayout is inside of a ListView. For the ImageView I want to right align I wrap it inside of a RelativeLayout and  set: ALIGN_PARENT_RIGHT. Here is what I tried in my LinearLayout class to right align my last ImageView:</p>
  
  <pre><code>public class CheckBoxifiedTextView extends LinearLayout implements OnClickListener
  {
  
            ////LAYOUT FOR THIS CLASS///////
  
           setLayoutParams(new ListView.LayoutParams(ListView.LayoutParams.FILL_PARENT,     ListView.LayoutParams.WRAP_CONTENT));
  
            this.setVerticalGravity(android.view.Gravity.CENTER_VERTICAL);
            this.setOrientation(HORIZONTAL);
            ///////////////////
  
  
            //ok now add grabber image:
            RelativeLayout.LayoutParams lp_imgGrabber = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
            lp_imgGrabber.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, RelativeLayout.TRUE);
            m_imgGrabber = new ImageView(context);
            m_imgGrabber.setImageResource(R.drawable.grabber);
  
  
            //TypedArray a=context.obtainStyledAttributes(R.styleable.TouchListView);
            //int grabberId = a.getResourceId(R.styleable.TouchListView_grabber, -1);
            //m_imgGrabber.setId(2131230808);
  
            RelativeLayout rel_layout_temp = new RelativeLayout(context);
            rel_layout_temp.setId(2131230808);
  
            rel_layout_temp.addView(m_imgGrabber);
  
            addView(rel_layout_temp,lp_imgGrabber);
  
  }
  </code></pre>
  
  <p>I ALSO tried:</p>
  
  <pre><code>FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(WRAP_CONTENT,WRAP_CONTENT,Gravity.RIGHT | Gravity.CENTER_VERTICAL)
  
  addView(m_imgGrabber,params);
  </code></pre>
  
  <p>which I got from this link:
  <a href="https://stackoverflow.com/questions/2945315/java-method-for-androidlayout-gravity">Java method for android:layout_gravity</a></p>
  
  <p>any ideas?</p>