[英]Weird issue with MaterialCardView
我正在尝试制作这样的圆形:
下面的代码在屏幕尺寸为 6.7" 的设备上运行良好。
<com.google.android.material.card.MaterialCardView
android:id="@+id/resultHolder"
android:layout_width="232dp"
android:layout_height="376dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_gravity="center"
android:gravity="center"
android:rotation="15"
android:outlineProvider="background"
android:theme="@style/Theme.MaterialComponents.Light"
app:cardBackgroundColor="@color/black"
app:cardCornerRadius="120dp"
app:cardElevation="0dp"
app:strokeColor="@color/green_neon"
app:strokeWidth="6dp">
<ImageView
android:src="@drawable/thumbnail"
android:id="@+id/resultImageView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:scaleType="centerCrop" />
</com.google.android.material.card.MaterialCardView>
但是当我在屏幕尺寸为 5.1" 的设备上测试应用程序时。我得到了这个:
你在设置
android:layout_width="232dp"
android:layout_height="376dp"
当您放置app:cardCornerRadius="120dp"
时,这是固定值,它非常高,它没有空间在较小的屏幕上完成 120dp 半径。使用背景可绘制或不同的解决方案。 此解决方案仅在您拥有的 6.7 英寸屏幕上才能完美运行
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.