java如何检查卡片内部的TextView通过水平滚动扩展recyclerView中的cardView大小?
我正在我的应用程序中创建一个读卡器,其中我使用Cardview使用Textview显示每个页面上下文。每个卡片视图中都有一个文本视图
在这里,我使用的是水平卷轴,其CardView高度为“wrap\u content”
问题
所以,现在的问题是,每个页面中的页面内容都是动态的。当我显示TextView内容时-当内容太大时,一些行在底部被截断,如下图所示-
我想在下一张卡片上显示,没有像下面这样的线被切断-
下面是每个布局项目的代码-
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:安卓="http://schemas.安卓.com/apk/res/安卓"
xmlns:app="http://schemas.安卓.com/apk/res-auto"
安卓:layout_width="match_parent"
安卓:layout_height="wrap_content"
安卓:layout_marginBottom="5dp"
>
<LinearLayout
安卓:layout_width="match_parent"
安卓:layout_height="wrap_content"
安卓:orientation="vertical"
>
<安卓.support.v7.widget.CardView
xmlns:card_view="http://schemas.安卓.com/apk/res-auto"
安卓:id="@+id/card_view_left"
安卓:layout_width="match_parent"
安卓: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"
安卓:layout_marginBottom="12dp"
安卓:layout_marginRight="10dp"
安卓:layout_marginLeft="10dp"
安卓:layout_marginTop="-7dp"
>
<LinearLayout
安卓:layout_width="match_parent"
安卓:layout_height="wrap_content"
安卓:orientation="vertical"
>
<TextView
安卓:id="@+id/tvPageNo"
安卓:layout_width="wrap_content"
安卓:layout_height="wrap_content"
安卓:layout_gravity="right"
安卓:text=""
安卓:layout_marginRight="20dp"
安卓:visibility="gone"
/>
<com.actinarium.aligned.TextView
安卓:layout_marginStart="10dp"
安卓:layout_marginEnd="10dp"
安卓:id="@+id/tv_content"
安卓:layout_width="match_parent"
安卓:layout_height="wrap_content"
安卓:textAppearance="@style/TextAppearance.AppCompat.Body1"
安卓:textSize="14sp"
app:leading="16sp"
app:firstLineLeading="24sp"
安卓:layout_marginBottom="10dp"
/>
</LinearLayout>
</安卓.support.v7.widget.CardView>
<View
安卓:id="@+id/viewPageUnderLine"
安卓:layout_width="fill_parent"
安卓:layout_height="2dp"
安卓:background="#c0c0c0"
安卓:layout_marginTop="10dp"
安卓:layout_marginLeft="50dp"
安卓:layout_marginRight="50dp"
安卓:visibility="gone"
/>
</LinearLayout>
<com.wang.avi.AVLoadingIndicatorView
安卓:id="@+id/loading_indicator"
安卓:layout_centerInParent="true"
安卓:layout_width="wrap_content"
安卓:layout_height="wrap_content"
app:indicatorName="LineScaleIndicator"
app:indicatorColor="@color/colorOrange"
/>
</RelativeLayout>
# 1 楼答案
最好的方法是设置android:maxLines=“10”和android:minLines=“10”。然后,父cardview的高度应与textview匹配。 如果有任何文本需要截断,则将截断的文本放入下一个cardview,该cardview也遵循上述规则