如果你想改变cardview的大小比根据文本尺寸比改变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>
你能请张贴布局XML?你的卡位有一个固定的大小? –
是的,它确实.----- – eli
为什么你不使用wrap_content? 如果你想有不同的大小,当你改变字体大小的大小,然后以编程方式更改卡片视图的大小。 –