7

So I have 2 textviews, one above the other, but when the second text view is populated the cut is cut off at the bottom. The textview, titled header_subtitle has the issue in question

Clearly Im missing something obvious, but dont know what. [Issue]1

Here is the code:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <include
        layout="@layout/search_bar_layout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:visibility="gone" />

    <RelativeLayout
        android:id="@+id/container_results"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:animateLayoutChanges="true"
        android:visibility="gone">

        <LinearLayout
            android:id="@+id/container_header"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:minHeight="@dimen/product_results_header_height"
            android:orientation="vertical"
            android:padding="?marginNormal">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="center_vertical"
                android:orientation="horizontal">

                <LinearLayout
                    android:layout_width="wrap_content"
                    android:layout_height="fill_parent"
                    android:layout_weight="1"
                    android:orientation="vertical" >

                    <FeatureTextView
                        android:id="@+id/header_title"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:ellipsize="end"
                        android:maxLines="2"
                        android:textAppearance="?taTitleXL" />

                    <FeatureTextView
                        android:id="@+id/header_subtitle"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:ellipsize="end"
                        android:maxLines="1"
                        android:layout_gravity="fill"
                        android:textAppearance="?taTitleXL"
                        android:padding="1sp"
                        android:visibility="gone"/>

                </LinearLayout>

                <Spinner
                    android:id="@+id/sort_spinner"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="?marginNormal" />

                <FeatureButton
                    android:id="@+id/refine_btn"
                    style="?buttonTertiary"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="?marginNormal"
                    android:text="@string/product_results_refine" />
            </LinearLayout>

            <SimpleFlowLayout
                android:id="@+id/category_links"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="?marginSmall"
                android:horizontalSpacing="?marginTiny"
                android:maxLines="2" />
        </LinearLayout>

        <include
            android:id="@+id/divider_horizontal"
            layout="@layout/divider_horizontal"
            android:layout_width="match_parent"
            android:layout_height="@dimen/divider_size"
            android:layout_below="@+id/container_header" />

        <FeatureTextView
            android:id="@+id/browse_no_results"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/divider_horizontal"
            android:layout_margin="?marginNormal"
            android:text="@string/product_results_no_results"
            android:textAppearance="?taTitleM"
            android:visibility="gone" />

        <GridView
            android:id="@+id/product_grid"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_below="@+id/divider_horizontal"
            android:numColumns="@integer/product_grid_cols"
            android:overScrollMode="@null"
            android:stretchMode="columnWidth" />

        <include
            android:id="@+id/progress_footer"
            layout="@layout/loading"
            android:layout_width="@dimen/progress_view_height"
            android:layout_height="@dimen/progress_view_height"
            android:layout_alignParentBottom="true"
            android:layout_centerHorizontal="true"/>

        <NoFilteredResultsView
            android:id="@+id/noFilteredResults"
            android:layout_below="@id/divider_horizontal"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:visibility="gone" />

        <include
            android:id="@+id/coach_mark"
            layout="@layout/view_coach_mark"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentEnd="true"
            android:layout_marginEnd="@dimen/coach_mark_margin_end"
            android:layout_marginTop="@dimen/coach_mark_margin_top" />
    </RelativeLayout>

</FrameLayout>
James King
  • 2,425
  • 7
  • 30
  • 45
  • 1
    Can you clarify what textview is cut off, and if possible provide a screenshot? Also, be careful with that nested layouts, probably you can have less levels in that layout hierarchy (just a performance and readability tip) – Daniel Ocampo Sep 17 '15 at 13:48
  • which textview is it? It looks like your layout isn't big enough. – Xjasz Sep 17 '15 at 13:49
  • Ah sorry, it is the header_subtitle – James King Sep 17 '15 at 13:49

3 Answers3

16

One of your LinearLayouts has height set to fill_parent. change it to wrap_content.

Also, remove the min_height attribute. Yout have two text fields in there, so it looks like you're totally OK with the second getting cut off.

It's kind of hard to tell what you're going for, but see if that helps.

Lii
  • 11,553
  • 8
  • 64
  • 88
BooleanCheese
  • 615
  • 12
  • 34
0

i know it's so late, but this is work like charm for me. add this code to your textview

android:ellipsize="marquee" android:layout_weight="1"

dewy
  • 21
  • 1
0

Merging two TextView tags into one solved my issue:

 <LinearLayout
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:gravity="center_vertical"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal">
        <TextView
            android:gravity="center_horizontal"
            android:id="@+id/app_version"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginStart="20dp"
            android:layout_marginEnd="2dp"
            android:text="© 1997 - 2020 "
            android:textColor="@color/black"
            android:textSize="12sp" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:id="@+id/text_digicollect"
            android:text="Onetime"
            android:textColor="@color/black"
            android:layout_marginStart="4dp"/>
    </LinearLayout>

Changing to:

 <LinearLayout
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:gravity="center_vertical"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal">
        <TextView
            android:gravity="center_horizontal"
            android:id="@+id/app_version"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginStart="20dp"
            android:layout_marginEnd="2dp"
            android:text="© 1997 - 2020 OneTime"
            android:textColor="@color/black"
            android:textSize="12sp" />
    </LinearLayout>
Adrian Mole
  • 49,934
  • 160
  • 51
  • 83
Sriraksha
  • 459
  • 1
  • 8
  • 15