【发布时间】:2021-04-01 09:20:31
【问题描述】:
CardView 中的阴影不起作用。当我在卡片视图中放置任何东西时,卡片视图中的角落也消失了。在 Android Studio 中的 Preview 工具看起来非常好,但对于我所有的设备来说看起来并不相似。 我在 Android 9.0 上工作。这个版本有问题吗?
我的材料设计版本 实现(“com.google.android.material:material:1.3.0”)
Preview in Android Studio tools
What showing on my tablet screen
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="130dp"
android:layout_height="180dp"
android:layout_margin="10dp"
android:background="@android:color/transparent">
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="5dp"
app:cardBackgroundColor="@color/white"
app:cardCornerRadius="5dp"
app:cardElevation="4dp"
app:cardPreventCornerOverlap="true"
app:cardUseCompatPadding="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="@+id/relative_image_view"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHeight_percent="0.75"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ImageView
android:id="@+id/itemImage"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:background="@drawable/emaenu_game"
android:contentDescription="@string/picture"
android:scaleType="centerCrop" />
</RelativeLayout>
<View
android:id="@+id/view10"
android:layout_width="match_parent"
android:layout_height="0dp"
android:background="@color/main_emenu"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHeight_percent="0.25"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/relative_image_view" />
<TextView
android:id="@+id/tv_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:fontFamily="@font/poppins"
android:gravity="center"
android:minHeight="0dp"
android:paddingStart="15dp"
android:paddingTop="2dp"
android:paddingEnd="15dp"
android:text="Water Flow"
android:textAllCaps="false"
android:textColor="@color/black_emenu"
android:textSize="12sp"
android:textStyle="normal"
app:layout_constraintBottom_toBottomOf="@+id/view10"
app:layout_constraintEnd_toEndOf="@+id/view10"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/relative_image_view" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView>
</androidx.constraintlayout.widget.ConstraintLayout>
【问题讨论】:
标签: android android-layout kotlin android-cardview