Как проверить, что TextView внутри карты расширяет размер cardView в recyclerView с горизонтальной прокруткой? - PullRequest
0 голосов
/ 06 марта 2019

Я создаю один читатель в Моем приложении, где я использовал Cardview , чтобы показать контекст каждой страницы, используя Textview . Внутри каждого cardView есть один Textview.

Здесь я использую горизонтальную прокрутку с высотой CardView, равной "wrap_content" .

Задача

Итак, теперь проблема в том, что содержимое страницы на каждой странице является динамическим. В то время как я показываю TextView контент - когда контент слишком велик, некоторые строки обрезаются внизу, как показано на изображении ниже -

enter image description here

, который я хочу показать на следующей карте, где ни одна строка не обрезается, как показано ниже -

enter image description here

Вот код, приведенный ниже для каждого элемента макета-

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginBottom="5dp"
    >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        >

            <android.support.v7.widget.CardView
                xmlns:card_view="http://schemas.android.com/apk/res-auto"
                android:id="@+id/card_view_left"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                card_view:cardCornerRadius="5dp"
                card_view:contentPadding="10dp"
                card_view:cardBackgroundColor="@color/colorTransparent"
                card_view:cardElevation="4dp"
                card_view:cardMaxElevation="5dp"
                android:layout_marginBottom="12dp"
                android:layout_marginRight="10dp"
                android:layout_marginLeft="10dp"
                android:layout_marginTop="-7dp"
                >

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"

                    android:orientation="vertical"
                    >

                <TextView
                    android:id="@+id/tvPageNo"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"

                    android:layout_gravity="right"
                    android:text=""
                    android:layout_marginRight="20dp"
                    android:visibility="gone"

                    />

                <com.actinarium.aligned.TextView
                    android:layout_marginStart="10dp"
                    android:layout_marginEnd="10dp"
                    android:id="@+id/tv_content"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"

                    android:textAppearance="@style/TextAppearance.AppCompat.Body1"
                    android:textSize="14sp"

                    app:leading="16sp"
                    app:firstLineLeading="24sp"

                    android:layout_marginBottom="10dp"

                    />


                </LinearLayout>


            </android.support.v7.widget.CardView>

        <View
            android:id="@+id/viewPageUnderLine"
            android:layout_width="fill_parent"
            android:layout_height="2dp"
            android:background="#c0c0c0"

            android:layout_marginTop="10dp"
            android:layout_marginLeft="50dp"
            android:layout_marginRight="50dp"
            android:visibility="gone"
            />

    </LinearLayout>


    <com.wang.avi.AVLoadingIndicatorView
        android:id="@+id/loading_indicator"
        android:layout_centerInParent="true"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:indicatorName="LineScaleIndicator"
        app:indicatorColor="@color/colorOrange"

        />

</RelativeLayout>

1 Ответ

0 голосов
/ 06 марта 2019

Лучшим способом было бы установить android: maxLines = "10" и android: minLines = "10".Родительское представление карты должно иметь высоту, соответствующую тексту.Если какой-либо текст должен быть усечен, возьмите усеченный текст и поместите его в следующую карточку, которая также следует приведенным выше правилам.

...