是否可以将阴影颜色(从translationZ生成)从黑色更改为白色

时间:2018-10-04 22:26:03

标签: android

目前,我的卡片设计如下。

enter image description here

如您所见,喜欢卡片的布局周围有阴影。其实现如下。 (我没有使用CardView,因为它不能完全满足我的其他要求)

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/card_view"
    android:layout_marginLeft="8dp"
    android:layout_marginStart="8dp"
    android:layout_marginRight="8dp"
    android:layout_marginEnd="8dp"
    android:layout_marginTop="8dp"
    android:layout_marginBottom="0dp"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="?attr/cardSelector"
    android:minHeight="48dp"
    android:stateListAnimator="@animator/lift_up"
    android:clickable="true" >
    ...
</FrameLayout>

阴影效果是由lift_up.xml引起的。如下。

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item
        android:state_enabled="true"
        android:state_pressed="true">
        <objectAnimator
            android:duration="@android:integer/config_shortAnimTime"
            android:propertyName="translationZ"
            android:valueTo="4dip"
            android:valueType="floatType" />
    </item>
    <item>
        <objectAnimator
            android:duration="@android:integer/config_shortAnimTime"
            android:propertyName="translationZ"
            android:valueTo="2dip"
            android:valueType="floatType" />
    </item>
</selector>

我需要在我的应用中提供黑色主题。我重新设计了看起来像这样的卡片。

enter image description here

由于阴影的颜色为黑色,因此在黑色主题下不可见。

我想知道,我是否可以将阴影更改为白色?如果是,怎么办?谢谢。

0 个答案:

没有答案
相关问题