learn_andrd
learn_andrd

Reputation: 1046

Table layout span not working properly

I am trying to implementing a table layout but gap comes in between the left border and first column of the screen.

Secondly, I am not able to give required width to my spinner in first row of screen which always takes full width of screen.

I have tried with different permutations of code with stretch columns and layout_span, but they don't seem to work.

 <TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
         android:paddingLeft="0dp>![enter image description here][1]





            <TableRow>
                <TextView
                    android:layout_column="1"
                    android:text="Adult 1"
                    android:layout_marginBottom="5dp"
                    android:layout_marginTop="10dp"
                    android:layout_width="wrap_content"
                    style="@style/text"/>


                <Spinner
                   android:layout_width="20dp"
                    android:layout_marginLeft="2dip"
                   android:layout_column="2"
                    android:layout_height="30dp"
                    android:layout_marginTop="10dp"
                     android:layout_marginBottom="5dp"
                    android:background="@drawable/select_spinner"
                    android:entries="@array/Passenger_title"/>



                <EditText

                  android:id="@+id/First_Name"
                  android:layout_column="3"
                  android:layout_width="wrap_content"

                  android:layout_height="30dp"
                  android:layout_marginTop="10dp"
                  style="@style/Edit_box_background"
                  android:layout_marginLeft="5dip"
                   android:layout_marginBottom="3dp"
                  android:textColor="#B3B3B3"
                  android:hint=" First Name  "
                  android:textAppearance="?android:attr/textAppearanceSmallInverse"
                  android:padding="3dip"/>

                <EditText

                 android:id="@+id/Last_Name"
               android:layout_column="4"
                   android:layout_width="wrap_content"

                 android:layout_height="30dp"
                 android:layout_marginTop="10dp"
                 style="@style/Edit_box_background"
                 android:layout_marginLeft="3dip"
                  android:layout_marginBottom="5dp"
                 android:textColor="#B3B3B3"
                 android:hint=" Last Name  "
                 android:textAppearance="?android:attr/textAppearanceSmallInverse"
                 android:padding="3dip"/>


            </TableRow>

Upvotes: 1

Views: 2342

Answers (1)

Arpit Garg
Arpit Garg

Reputation: 8546

firstly looking over your scenario I firstly recommend not to use android:layout_column="1" and layout_span unless required.By Default all items added to a TableRow would be added to right starting from first column.

And after give desired width to your Spinner.

Also one more mistake that you are making android:layout_column="0" you forgot to use it uses first column as index 0 not 1.

Hope My suggestion help you out and link you to right direction.

Upvotes: 1

Related Questions