ExpandableCardView文本不完全可见

时间:2018-07-13 04:33:35

标签: android textview android-cardview expandable

我正在使用this library来实现可扩展卡片,除了两个主要问题之外,它都可以正常工作:

  1. 它要求最低api级别为21,而以前的最低api级别为16。在较低的设备上是否可以正常工作?在库的清单文件中可以选择重写此选项,但我认为这不是一个好主意。

  2. 我有如下所示的布局,其中包含带有textview的另一个布局,但是文本没有完全显示,只有第一行可见。这是布局:

         <com.alespero.expandablecardview.ExpandableCardView
                android:id="@+id/focusCardLayout"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/metaCard"
                android:layout_marginBottom="10dp"
                app:expandOnClick="true"
                app:inner_view="@layout/session_inner_card_focus_pts_layout"
                app:title="Focus Points" />
    

inner_view布局:

<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
   android:layout_width="match_parent"
   android:layout_height="wrap_content"
   xmlns:tools="http://schemas.android.com/tools"
   android:id="@+id/focusPointsTV"
   android:layout_margin="5dp"
   android:layout_marginBottom="10dp"
   android:text="You cannot win matches without scoring points so it's important your players can shoot accurately."
   android:textSize="18sp"
   android:padding="10dp">

 </TextView>

这是我的布局或库中的错误吗?我已经将input_type设置为短/长消息,仍然没有效果。 还有其他expanding-collapsing个cardviews android设备吗?谢谢。

1 个答案:

答案 0 :(得分:1)

我尝试了您的代码,但我认为您的问题来自图书馆。

我知道一个lib也可以解决您的问题,即this library

<!-- sample xml -->
  <com.ms.square.android.expandabletextview.ExpandableTextView
      xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:expandableTextView="http://schemas.android.com/apk/res-auto"
      android:id="@+id/expand_text_view"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      expandableTextView:maxCollapsedLines="4"
      expandableTextView:animDuration="200">
      <TextView
          android:id="@id/expandable_text"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_marginLeft="10dp"
          android:layout_marginRight="10dp"
          android:textSize="16sp"
          android:textColor="#666666" />
      <ImageButton
          android:id="@id/expand_collapse"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:padding="16dp"
          android:layout_gravity="right|bottom"
          android:background="@android:color/transparent"/>
  </com.ms.square.android.expandabletextview.ExpandableTextView>

这对我来说很有效,希望对您有所帮助。