开发者

how to expand text box within TableLayout

i'm currently attempting to work out how to have 4 text boxes, 2 per row in horizontal v开发者_如何学编程iew. i don't have a problem implementing this with a tablelayout/ tablerow where the text boxes of equal sizes.

i.e:

box1 box2

box3 box4

code for above:

<?xml version="1.0" encoding="UTF-8"?>

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:gravity="center"
    android:paddingLeft="20dip"
    android:paddingRight="20dip" 
    >




        <TableLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:stretchColumns="*">

            <!-- start of 1st Row -->

                <TableRow>


                    <EditText
                        android:id="@+id/textbox1"
                        android:layout_height="wrap_content"
                        android:layout_width="fill_parent"
                        android:background="@android:drawable/editbox_background"
                        android:padding="5dip" />   

                    <EditText
                        android:id="@+id/textbox2"
                        android:layout_height="wrap_content"
                        android:layout_width="fill_parent"
                        android:background="@android:drawable/editbox_background"
                        android:padding="5dip"



            />

            </TableRow> <!-- end of of 1st Row -->

            <!--  2nd Row -->

                    <TableRow>


                    <EditText
                        android:id="@+id/textbox3"
                        android:layout_height="wrap_content"
                        android:layout_width="fill_parent"
                        android:background="@android:drawable/editbox_background"
                        android:padding="5dip"
                        android:paddingRight="15dip"


            />



                    <EditText
                       android:id="@+id/textbox4"
                       android:layout_height="wrap_content"
                       android:layout_width="fill_parent"
                       android:background="@android:drawable/editbox_background"
                       android:padding="5dip"
                       android:layout_weight="1"
                       />




                </TableRow> <!-- end of of 2nd Row -->


            </TableLayout>


            </LinearLayout>

what i'd like to try is to have is the 4th box to be a larger size.

box1 box4 <---spans the length of box1-3

box2

box3

how can i do this?

my code to to align boxes but i'd like to know how i can expand the size of box4:

<?xml version="1.0" encoding="UTF-8"?>

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:gravity="center"
    android:paddingLeft="20dip"
    android:paddingRight="20dip" 
    >



        <TableLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:stretchColumns="*">

            <!-- start of 1st Row -->

                <TableRow>


                    <EditText
                        android:id="@+id/textbox1"
                        android:layout_height="wrap_content"
                        android:layout_width="fill_parent"
                        android:background="@android:drawable/editbox_background"
                        android:padding="5dip" />   

                    <EditText
                        android:id="@+id/textbox4"
                        android:layout_height="wrap_content"
                        android:layout_width="fill_parent"
                        android:background="@android:drawable/editbox_background"
                        android:padding="5dip"
                        android:layout_weight="1"



            />

            </TableRow> <!-- end of of 1st Row -->

            <!--  2nd Row -->

                    <TableRow>


                    <EditText
                    android:id="@+id/textbox2"
                        android:layout_height="wrap_content"
                        android:layout_width="fill_parent"
                        android:background="@android:drawable/editbox_background"
                        android:padding="5dip"



            />


            <TextView>

            </TextView> 






                </TableRow> <!-- end of of 2nd Row -->


            <TableRow>

                <EditText
                    android:id="@+id/textbox3"
                    android:layout_height="wrap_content"
                    android:layout_width="fill_parent"
                    android:background="@android:drawable/editbox_background"
                    android:padding="5dip"/>


                <TextView>


                </TextView>


            </TableRow>


            </TableLayout>


            </LinearLayout>

thanks!


Example:

<TableRow
    android:id="@+id/tableRow6"
    android:layout_height="wrap_content" android:layout_width="fill_parent">
    <Button
        android:layout_span="2"
        android:layout_height="wrap_content" android:layout_gravity="center" 
                    android:layout_width="fill_parent" android:text="Submit" 
                    android:id="@+id/submitBtn">
            </Button>
</TableRow>

Try using android:layout_span="2" as in the above example, where 2 is the number of columns to span (like merge)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜