如何检查内部卡的TextView扩展了使用水平滚动的recyclerView中的cardView大小?

问题描述 投票:0回答:1

我在My Application中创建了一个阅读器,我使用Cardview使用Textview显示每个页面上下文。每个cardView中都有一个Textview。

在这里,我使用具有CardView高度的Horizo​​ntal scroll作为“wrap_content”。

Problem

所以,现在的问题是每个页面中的页面内容都是动态的。当我显示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>
java android xml textview cardview
1个回答
0
投票

最好的方法是设置android:maxLines =“10”和android:minLines =“10”。然后,父cardview应具有与textview匹配的高度。如果任何文本被截断,则将截断的文本放在下一个也遵循上述规则的cardview中。

© www.soinside.com 2019 - 2024. All rights reserved.