我试图在 CardView 下填充 TextView ,但信息不完整。如何使 CardView 自动调整大小以适应填充 TextView 的任何类型的信息
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/card_view"
android:layout_marginBottom="16dp"
card_view:cardCornerRadius="7dp"
card_view:contentPaddingTop="20dp"
card_view:cardUseCompatPadding="true"
card_view:contentPaddingLeft="50dp"
card_view:contentPaddingRight="50dp"
card_view:contentPadding="8dp"
android:layout_width="352dp"
android:layout_height="match_parent"
>
<LinearLayout
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="SYNOPSIS"
android:paddingBottom="20dp"
android:textSize="12dp"
android:textStyle="bold"
android:textColor="#300145"
/>
<TextView
android:id="@+id/synopsis_txt"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:text="SYNOPSIS TWO"
android:textSize="12dp"
android:paddingRight="20dp"
android:textColor="#000000"
android:paddingLeft="20dp" />
</LinearLayout>
</android.support.v7.widget.CardView>
最佳答案
在卡片 View xml 文件上替换:
android:layout_height="match_parent" with android:layout_height="wrap_content"
在 TextView 中 @+id/synopsis_txt :
android:layout_height="30dp" with android:layout_height="wrap_content"
关于java - 当 textView 填充数据或信息时,如何使 CardView 自动调整大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38731221/