Как увеличить размер cardView на основе размера текста?

Если я изменю размер текста, это переполнит мой просмотр карты. Как мне изменить размер просмотра карт, чтобы приспособиться к текущему размеру просмотра текста?

<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/cardview"
android:layout_width="match_parent"
android:layout_height="120dp"
card_view:cardElevation="1.5dp"
card_view:cardCornerRadius="0dp"
android:onClick="OnClick">

1 ответ

Если вы хотите изменить размер карты, чем в соответствии с размером текста, чем изменить android:layout_height="wrap_content"

<android.support.v7.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto"
        android:id="@+id/cardview"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        card_view:cardCornerRadius="0dp"
        card_view:cardElevation="1.5dp">

EX: я пытался

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.v7.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto"
        android:id="@+id/cardview"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        card_view:cardBackgroundColor="#85c7dc"
        card_view:cardCornerRadius="0dp"
        card_view:cardElevation="1.5dp">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:weightSum="2">

            <TextView
                android:id="@+id/txtDrVisit_DrName"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:gravity="center"
                android:text="ABC"
                android:textSize="25sp"
                android:textStyle="bold" />

            <TextView
                android:id="@+id/txtDrVisit_DrDetails"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:gravity="center"
                android:text="ABC"
                android:textSize="45sp"
                android:textStyle="normal" />
        </LinearLayout>

    </android.support.v7.widget.CardView>
</LinearLayout>
Другие вопросы по тегам