0

In my development i am placing three Textviews inside the Tablerow, those Texviews are giving some top margins due to that reason some lower case letter warping the content because Textviews are overflowing the Tablerow. Please suggest me the proper solution.

Thanks in advance.

<?xml version="1.0" encoding="utf-8"?>
 <TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center_horizontal"
                    android:orientation="vertical" >
     <TableRow
                        android:background="#f0f"
                        android:id="@+id/tr_abspath"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content">

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="Path"
                            style="@style/TextViewStyle.buddyNameTxt" />

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginLeft="5dp"
                            android:layout_marginRight="5dp"
                            android:text=":"
                            android:textColor="#333" />

                        <TextView
                            android:background="#ff0"
                            android:id="@+id/tv_abspath"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:includeFontPadding="false" android:text="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.jpg"
                            android:textColor="#666" />
                    </TableRow>

                </TableLayout>
Rayani
  • 15
  • 6

3 Answers3

0

Without screenshots, it is difficult to understand exactly what issue you are experiencing. However, regarding the top margins, it looks like you have coded some top margins into two of your textviews: android:layout_marginTop="5dp".

Try removing that margin to see if that fixes your issue.

HoppedUpDev
  • 71
  • 1
  • 4
0

In your XML, you have used both margin and padding. If your intention is only to set a space between the text and the table row border (Within the table row), use only padding.

If your intention is to set a space between each table rows, use margin.

Based on the design need, please modify the code sample. Hope this helps :)

Read this link for a clear explanation.

Difference between a View's Padding and Margin

Community
  • 1
  • 1
Prem
  • 4,823
  • 4
  • 31
  • 63
  • I already aware of the difference between padding and margin, and i know that problem with neither padding and margin that problem is because of text view only anyhow i modified my code as for your suggestions please check and let me know the solution. – Rayani Jul 24 '14 at 06:01
0

I had a similar problema recently (Also tried to set margin/padding to 0dp) and it only worked when I wrapped the TextView (with includeFontPadding=false) inside a LinearLayout (with gravity set to "top").

celk
  • 11
  • 1