java - 如何通过水平滚动检查卡片内的 TextView 扩展了 recyclerView 中的 cardView 大小?
问题描述
我在我的应用程序中创建了一个阅读器,我使用Cardview来使用Textview显示每个页面上下文。每个 cardView 内都有一个Textview。
在这里,我使用具有 CardView 高度为"wrap_content"的水平滚动。
问题
所以,现在的问题是每个页面中的页面内容是动态的。当我显示TextView内容时 - 当内容太大时,一些行在底部被切断,如下图所示 -
我想在下一张卡片中显示,其中没有线被切断,如下所示 -
下面是每个布局项的代码 -
<?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>
解决方案
最好的方法是设置 android:maxLines="10" 和 android:minLines="10"。父卡片视图应该具有与文本视图匹配的高度。如果要截断任何文本,则将截断的文本放入同样遵循上述规则的下一个卡片视图中。
推荐阅读
- java - 如何使用 NiFi 中的新 DBCPConnectionPoolLookup 列出一组数据库中的数据库表?
- php - 未找到使用 laravel 5.4 发送电子邮件的视图
- javascript - 最大化这个while循环的效率
- javascript - 在 JS 中根据背景颜色切换元素颜色
- django - UpdateView 模板只显示一个相关模型的pk,如何让它显示其他字段?
- lwip - lwIP - tcp_alloc 和 tcp_new 之间的区别
- c++ - 如何在C ++中的opencv中打开两个透明图像
- video-streaming - 在 html5 中将图像 url 列表作为视频播放
- python - 使用 groupby 在 Pandas 中创建字典
- autodesk-forge - 使用 Autodesk Forge Viewer MarkupsCore 扩展时,如何在模型中获得一致的标记字体大小?