Check out the layout_weight parameter. I think you'll get what you
want by specifying the following:

for the Button, add android:layout_weight="0"
for the TextView, add android:layout_weight="1"

Also, you don't really need TableLayouts with single TableRows. You
could get the same effect with a LinearLayout with horizontal
orientation or a RelativeLayout. TableLayouts are really most useful
when your presentation requires equal width columns, which you don't
have here.

Best regards,
Brian Cooley

On May 24, 11:41 am, jgostylo <[email protected]> wrote:
> The issue is that the table I am making extends itself off the right
> side of the dialog window.
>
> It seems like it only does this when one of the components in the
> table is a textview with enough text to cover multiple lines.
>
> Someone suggested that I try using a gridview instead of a table
> layout but everything seems so similar between the two and I don't see
> why mine does not work.
>
> The gist of the xml is that I am setting up tables inside my vertical
> linearlayout that is going in a dialog window.  The tables are set up
> with wrap_content for height and fill_parent for width.  Each table is
> one row and the row has a button and a textview.  I want the textview
> to stretch to take whatever space the button does not take.  When the
> button comes first the textview goes beyond the right edge of the
> screen.  When the textview comes first it takes the entire screen
> width and pushes the button off the screen.  It seems like the
> tablelayout believes its parent is wider than it actually is.
>
> Can someone tell me what I am doing wrong?
>
> Here is the XML:
>
> <?xml version="1.0" encoding="utf-8"?>
> <LinearLayout
>     xmlns:android="http://schemas.android.com/apk/res/android";
>     android:orientation="vertical"
>     android:layout_height="wrap_content"
>     android:layout_width="fill_parent"
>     >
>     <!-- TABLE WHERE THE TEXTVIEW COMES FIRST -->
>     <TableLayout
>         android:id="@+id/parcelinfo_moveout_table"
>         android:layout_height="wrap_content"
>         android:layout_width="fill_parent"
>         android:layout_gravity="center"
>         android:stretchColumns="0"
>         >
>         <TableRow>
>             <TextView
>                 android:id="@+id/moveout_army"
>                 android:layout_width="wrap_content"
>                 android:layout_height="wrap_content"
>                 android:textSize="14sp"
>                 android:text="@string/moveout_text"
>             />
>             <Button
>                 android:id="@+id/moveout_button"
>                 android:layout_width="wrap_content"
>                 android:layout_height="wrap_content"
>                 android:layout_marginTop="5dip"
>                 android:text="@string/moveout_button"
>             />
>         </TableRow>
>     </TableLayout>
>     <!-- TABLE WHERE THE BUTTON COMES FIRST -->
>     <TableLayout
>         android:id="@+id/parcelinfo_movein_table"
>         android:layout_height="wrap_content"
>         android:layout_width="fill_parent"
>         android:layout_gravity="center"
>         android:stretchColumns="1"
>         >
>         <TableRow>
>             <Button
>                 android:id="@+id/movein_button"
>                 android:layout_width="wrap_content"
>                 android:layout_height="wrap_content"
>                 android:layout_marginTop="5dip"
>                 android:text="@string/movein_button"
>             />
>             <TextView
>                 android:id="@+id/movein_army"
>                 android:layout_width="wrap_content"
>                 android:layout_height="wrap_content"
>                 android:textSize="14sp"
>                 android:text="@string/movein_text"
>             />
>         </TableRow>
>     </TableLayout>
>     <TextView
>         android:id="@+id/notpresent_content"
>         android:layout_width="wrap_content"
>         android:layout_height="wrap_content"
>         android:textColor="@color/text_red"
>         android:layout_marginTop="15dip"
>         android:text="@string/parcelinfo_notpresent"
>     />
>     <TableLayout
>         android:id="@+id/parcelinfo_buttontable"
>         android:layout_height="wrap_content"
>         android:layout_width="wrap_content"
>         android:layout_gravity="center"
>         android:stretchColumns="*"
>         >
>         <TableRow>
>             <Button
>                 android:id="@+id/parcelinfo_attack_button"
>                 android:layout_width="wrap_content"
>                 android:layout_height="wrap_content"
>                 android:layout_marginTop="5dip"
>                 android:text="@string/attack"
>             />
>             <Button
>                 android:id="@+id/parcelinfo_close_button"
>                 android:layout_width="wrap_content"
>                 android:layout_height="wrap_content"
>                 android:layout_marginTop="5dip"
>                 android:text="@string/close"
>             />
>         </TableRow>
>     </TableLayout>
> </LinearLayout>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group 
> athttp://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to