java - 当 textView 填充数据或信息时,如何使 CardView 自动调整大小

标签 java android

我试图在 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/

相关文章:

java - 模拟具有静态方法的类时发生异常

android - Intellij 13 在尝试将 Android 应用程序安装/启动到 USB 设备时出错

android - 如何管理 Realm 实例?

java - 贾斯珀 : Compiling same jrxml file into multiple output formats

java - 尝试连接当时不可用的远程设备时,蓝牙聊天应用程序出现“服务发现失败”错误

java - 具有共同偏好的不当行为

Android Alarm AlarmManager提供的四种Alarm有什么区别,什么时候用什么?

android - 更改屏幕大小(牛轧糖)

java - 给定一个格式字符串 (String.format()/Formatter) 是否有一种简单的方法来获取预期的参数类型?

java - 使用 xml 和注解配置两次加载 Spring 上下文