有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java如何在textView中填充数据或信息时自动调整CardView的大小

我试图在CardView下填充TextView,但信息不完整。如何使CardView根据填充TextView的任何信息自动调整大小

<安卓.support.v7.widget.CardView
    xmlns:card_view="http://schemas.安卓.com/apk/res-auto"
    安卓:id="@+id/card_view"
    安卓: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"
    安卓:layout_width="352dp"
    安卓:layout_height="match_parent"
    >
    <LinearLayout
        安卓:layout_width="match_parent"
        安卓:orientation="vertical"
        安卓:layout_height="match_parent">
        <TextView
            安卓:layout_width="wrap_content"
            安卓:layout_height="wrap_content"
            安卓:text="SYNOPSIS"
            安卓:paddingBottom="20dp"

            安卓:textSize="12dp"
            安卓:textStyle="bold"
            安卓:textColor="#300145"


            />
        <TextView
                安卓:id="@+id/synopsis_txt"
                安卓:layout_width="wrap_content"
                安卓:layout_height="30dp"
                安卓:text="SYNOPSIS TWO"
                安卓:textSize="12dp"
                安卓:paddingRight="20dp"
                安卓:textColor="#000000"
            安卓:paddingLeft="20dp" />

    </LinearLayout>
</安卓.support.v7.widget.CardView>

共 (1) 个答案

  1. # 1 楼答案

    在卡视图xml文件上,替换:

    android:layout_height="match_parent" with android:layout_height="wrap_content" 
    

    在文本视图@+id/Synosis_txt中:

    android:layout_height="30dp" with android:layout_height="wrap_content"