开发者

Android: Table Layout alignment problem

Hi I have a LinearLayout, inside there is a TableLayout 1st row, contains a center aligned image; 2nd/3rd/... rows, contains two EditText fields. I need all the rows from 2nd row should be left aligned ("Name": "Value").

But in my case, "Name" part is left aligned, that is ok, but the "Value" part is starting from above row's image's right edge..

Can anybody help to fix this.

Here is my layout:

<ScrollView android:id="@+id/ScrollView01"
    android:layout_width="wrap_content" android:scrollbars="vertical"
    android:layout_marginLeft="8dp" android:layout_marginRight="8dp"
    android:minWidth="310dp" android:scrollbarStyle="insideOverlay"
    android:layout_height="wrap_content" android:paddingBottom="20dp">

    <TabHost android:id="@android:id/tabhost"
        android:layout_width="fill_parent" android:layout_height="fill_parent">
        <LinearLayout android:orientation="vertical"
            android:layout_width="fill_parent" android:layout_height="fill_parent">

            <TabWidget android:id="@android:id/tabs"
                android:layout_width="fill_parent" android:visibility="invisible"
                android:layout_height="1dip" />

            <FrameLayout android:id="@android:id/tabcontent"
                android:layout_width="fill_parent" android:layout_height="fill_parent">

                <!--  Details tab -->

                <LinearLayout android:id="@+id/tabContentDetails"
                    android:layout_width="fill_parent" android:orientation="vertical"
                    android:layout_height="wrap_content">

                    <TableLayout android:id="@+id/TableLayout01"
                        android:layout_width="fill_parent" android:layout_height="wrap_content"
                        android:gravity="center" android:stretchColumns="0"
                        android:background="@drawable/transparent_border_shape">
                        <TableRow android:id="@+id/TableRow01"                              
                            android:gravity="center">
                                <ImageView android:id="@+id/update_details_img"
                                    android:layout_width="200dip" android:layout_height="200dip"
                                    android:src="@drawable/q_silhouette" android:paddingTop="10dp"
                                    android:scaleType="fitXY" android:gravity="center">
                                </ImageView>
                            </TableRow>
                            <TableRow android:layout_marginBottom="5dip">
                                <TextView android:id="@+id/csTitle"
                                    android:padding="3dip" android:textSize="7pt"
                                    android:textColor="@color/Black"  />
                            </TableRow>                         
                            <TableRow android:layout_marginBottom="5dip">                               
                                <TextView android:text="Date ed:" android:padding="3dip"
                                    android:textColor="@color/registration_fields_title"
                                    android:textSize="7pt" />
                                <TextView android:id="@+id/csDated"
                                    android:padding="3dip" android:textSize="7pt"
                                    android:textColor="@color/Black"  />                                
                            </TableRow>
                            <TableRow android:layout_marginBottom="5dip">
                                <TextView android:text="Posted By:" android:padding="3dip"
                                    android:textColor="@color/registration_fields_title"
                                    android:textSize="7pt" />
                                <TextView android:id="@+id/csPostedBy"
                                    android:padding="3dip" android:textSize="7pt"
                                    android:textColor="@color/Black"  />
                            </TableRow>
                            <TableRow android:layout_marginBottom="5dip">
                                <TextView android:text="Description:" android:padding="3dip"
                                    android:textColor="@color/registration_fields_title"
                                    android:textSize="7pt" />
                            </TableRow>

                            <TableRow android:id="@+id/TableRow01"
                                android:layout_width="wrap_content" android:layout_height="wrap_content">
                                <TextView android:layout_开发者_高级运维width="fill_parent" android:layout_height="wrap_content"
                                    android:id="@+id/csDescription" android:textColor="@color/Black"
                                    android:paddingTop="2dp" android:paddingLeft="2dp"
                                    android:scrollbars="vertical" 
                                    android:minWidth="290dp" android:minHeight="90dp" android:isScrollContainer="true"
                                    android:background="@drawable/transparent_border_shape">

                                </TextView>
                            </TableRow>
                    </TableLayout>
                </LinearLayout>

                <!--  Comments tab -->

                <LinearLayout android:id="@+id/tabContentComments"
                    android:layout_width="fill_parent" android:orientation="vertical"
                    android:layout_height="fill_parent"></LinearLayout>
            </FrameLayout>
        </LinearLayout>
    </TabHost>
</ScrollView>

Thanks in adavance - Venkat


set the gravity of table layout to center and make sure the width is fill_parent. also use android:stretchColumns="field"

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜