tags:

views:

74

answers:

1

He is an example of my TextView, which goes off the right side of the screen. I tried setting paddings and stuff, but nothing seemed to work. Any ideas? Here is my hierarchy, ScrollView,TableLayout

  <TableRow>
   <TextView
    android:layout_column="1"
       android:id="@+id/text_price"
       android:layout_width="fill_parent"
       android:layout_height="wrap_content"
       android:inputType="textCapCharacters"
       android:padding="2dip"
       android:text="@string/game_price"
   />
   <EditText
       android:id="@+id/gameprice"
       android:inputType="textCapCharacters"
       android:gravity="right"
       android:minWidth="120dip"
   />
  </TableRow>
A: 

Try setting the width of the textview to wrap_content, remove the layout_column=1 (not necessary, afaik), and set the height and width of the edittext to wrap_content.

Anyway it's weird to have a textview filling the screen and an edittext to its right with a width of at least 120dip. If you stick to a TableLayout maybe you'll have to play with the weights of the elements, tho I'm not too sure of how this works in a tableLayout. To fill the width of the screen, define that in the TableLayout with fill_parent.

If what you want is a TextView taking all the space left by the EditText placed to the right, a RelativeLayout would do the work

   <RelativeLayout>
       <EditText
           android:id="@+id/gameprice"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:inputType="textCapCharacters"
           android:gravity="right"
           android:minWidth="120dip"/>
        <TextView
           android:id="@+id/text_price"
           android:layout_width="fill_parent"
           android:layout_height="wrap_content"
           android:inputType="textCapCharacters"
           android:padding="2dip"
           android:text="@string/game_price"

           android:layout_toLeftOf="@id/gameprice"/>
    </RelativeLayout>

You'll need to play with the placement of the EditText, the TextView will stick to its left.

Maragues