Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I'm having this issue where my TextView inside a TableRow is getting the bottom of the second line cropped.

The only way to solve this that I found was to add margins to the FAV image on the left but it just ruined the rest of the design. Can someone explain to me why this is happening and how to fix it?

Here's the code:

    <LinearLayout
        android:id="@+id/item"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/card_bg"
        android:orientation="vertical" >

        <TableLayout
            android:id="@+id/link_title_favicon"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:paddingTop="6dp" >

            <TableRow
                android:layout_width="fill_parent"
                android:layout_height="wrap_content" >

                <com.loopj.android.image.SmartImageView
                    android:id="@+id/expandable_toggle_button"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:src="@drawable/favicon_example2" />

                <TextView
                    android:id="@+id/linkTitle0001"
                    android:layout_width="wrap_content"
                    android:layout_height="fill_parent"
                    android:layout_weight="1"
                    android:layout_gravity="center_vertical"
                    android:ellipsize="end"
                    android:fontFamily="sans-serif-condensed"
                    android:maxLines="2"
                    android:paddingLeft="6dp"
                    android:text="@string/link_title_001"
                    android:textColor="#777777"
                    android:textSize="17sp" />
            </TableRow>
        </TableLayout>

        <TextView
            android:id="@+id/linkDesc0001"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/link_title_favicon"
            android:layout_marginTop="4dp"
            android:fontFamily="sans-serif"
            android:maxLines="1"
            android:text="@string/link_desc_001"
            android:textColor="#acacac"
            android:textSize="13sp" />

        <ImageView
            android:id="@+id/labelSource0001"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/linkDesc0001"
            android:layout_marginTop="4dp"
            android:background="@drawable/card_label" />
    </LinearLayout>

    <LinearLayout
        android:id="@+id/expandable"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/labelSource0001"
        android:background="@drawable/expmenu_bg"
        android:orientation="horizontal" >

        <!--
            <ImageView
            android:id="@+id/link_preview_btn"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:layout_weight="1"
            android:onClick="onClickPreview"
            android:src="@drawable/link_preview_icon"
            android:src="@drawable/link_preview_icon" />
        -->

        <ImageView
            android:id="@+id/link_forward_btn"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:layout_weight="1"
            android:paddingTop="2dp"
            android:src="@drawable/link_forward_icon" />

        <ImageView
            android:id="@+id/link_share_btn"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:layout_weight="1"
            android:src="@drawable/link_share_icon" />

        <ImageView
            android:id="@+id/link_info_btn"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:layout_weight="1"
            android:src="@drawable/link_info_icon" />

        <ImageView
            android:id="@+id/link_devices_btn"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:layout_weight="1"
            android:paddingTop="2dp"
            android:src="@drawable/link_devices_icon" />

        <ImageView
            android:id="@+id/link_copyurl_btn"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:layout_weight="1"
            android:src="@drawable/link_copyurl_icon" />

        <ImageView
            android:id="@+id/link_delete_btn"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:layout_weight="1"
            android:src="@drawable/link_delete_icon" />
    </LinearLayout>

</LinearLayout>

And here's the bg code in case it's needed:

 <?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <shape android:shape="rectangle"
            android:dither="true">

            <corners android:radius="2dp"/>

            <solid android:color="#aaaaaa" />

        </shape>
    </item>

    <item android:bottom="2dp">
        <shape android:shape="rectangle"
            android:dither="true">

            <corners android:radius="2dp" />

            <solid android:color="@android:color/white" />

            <padding android:bottom="6dp"
                android:left="6dp"
                android:right="6dp"
                android:top="4dp" />
        </shape>
    </item>
</layer-list>

Here's an image of my issue: Cropped Text

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
187 views
Welcome To Ask or Share your Answers For Others

1 Answer

Found the answer. Replace the TableLayout with a LinearLayout:

 <LinearLayout
            android:id="@+id/link_title_favicon"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:paddingTop="6dp"
            android:orientation="horizontal" >


                <com.loopj.android.image.SmartImageView
                    android:id="@+id/expandable_toggle_button"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:src="@drawable/favicon_example2"
                    android:layout_gravity="center_vertical" />

                <TextView
                    android:id="@+id/linkTitle0001"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:layout_gravity="center_vertical"
                    android:ellipsize="end"
                    android:fontFamily="sans-serif-condensed"
                    android:maxLines="2"
                    android:paddingLeft="6dp"
                    android:text="@string/link_title_001"
                    android:textColor="#777777"
                    android:textSize="17sp" />

        </LinearLayout>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...