Q:

How to align 2 views to the left and one to the right in linear layout?

<LinearLayout 
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >

 <CheckBox
     android:id="@+id/checkBox2"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:text="Learning a lot" />

<TextView
    android:id="@+id/ctv2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="  ?" />

                <SeekBar
    android:id="@+id/seekBar2"
    android:layout_width="100dp"    
    android:layout_height="wrap_content" 
    android:gravity="right"/>

</LinearLayout>

Thats the code in xml.
I want checkbox and textview next to each other left aligned and seekbar right aligned.I found topics similar to this but I wasn't able to found solution. hmmmmmmm ... Please help me ...

A:

add android:layout_weight="1" to the TextView that will tell the linear layout to give any extra space to the textview, which will move the seekbar to the right edge.

