TextView taking/consuming too much space above and below the text

橙三吉。 提交于 2019-12-12 00:24:56

问题


The text view encircled has too much space above and below its text. It is inside the text view (not above and below of it). I neither used margins nor paddings but it is remained there. The xml code is there.

    <TableRow
        android:id="@+id/tbRow"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/viewLineSeparator"
        android:layout_gravity="top"
        android:layout_marginBottom="2dp"
        android:layout_marginTop="1dp"
        android:gravity="top"
        android:weightSum="1.0" >
        <TextView
            android:id="@+id/tvReportAsAdult"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_gravity="left|top"
            android:layout_weight="0.60"
            android:clickable="true"
            android:gravity="left|top"
            android:maxLines="5"
            android:padding="11dp"
            android:text="@string/txtReportAsAdultText"
            android:textColor="#00BFFF"
            android:textSize="18sp" />
        <LinearLayout
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_gravity="right|center"
            android:layout_weight="0.40"
            android:gravity="center"
            android:weightSum="1.0" >

            <ImageButton />
            <ImageButton />
            <ImageButton />
            <ImageButton />

        </LinearLayout>
    </TableRow>

This tableRow is a child of a RelativeLayout which is further a child of ScrollView. And the space is only due to textview i.e. its neither due to imageviews nor tablerow.


回答1:


you are using

  android:padding="11dp"

which is setting 11 dp padding in all sides of the textview. use padding separately by using

paddingTop,paddingBottom,paddingLeft,PaddingRight



来源:https://stackoverflow.com/questions/16627237/textview-taking-consuming-too-much-space-above-and-below-the-text

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!