Cardview - 涟漪效应

时间:2016-12-21 15:25:56

标签: android android-cardview

我在这里看到了几个关于cardview涟漪效应的问题,但不知怎的,我无法让它发挥作用。

我有这个XML:

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
    android:id="@+id/card_bot2"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_above="@+id/card_bot1"
    android:layout_marginBottom="-8dp"
    android:layout_marginTop="-8dp"
    app:cardBackgroundColor="@color/BLACK1"
    app:cardCornerRadius="5dp"
    app:cardElevation="8dp"
    app:cardMaxElevation="0dp"
    app:cardPreventCornerOverlap="false"
    app:cardUseCompatPadding="true">

    <Button
        android:id="@+id/choiceButton1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="1dp"
        android:background="@null"
        android:fontFamily="serif-monospace"
        android:text="@string/astory_button1"
        android:textColor="@color/RED1"
        android:textSize="16sp"/>

</android.support.v7.widget.CardView>

<android.support.v7.widget.CardView
    android:id="@+id/card_bot1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_marginBottom="-8dp"
    android:layout_marginTop="-8dp"
    app:cardBackgroundColor="@color/BLACK1"
    app:cardCornerRadius="5dp"
    app:cardElevation="8dp"
    app:cardMaxElevation="0dp"
    app:cardPreventCornerOverlap="false"
    app:cardUseCompatPadding="true">


    <Button
        android:id="@+id/choiceButton2"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="1dp"
        android:background="@null"
        android:fontFamily="serif-monospace"
        android:text="@string/astory_button2"
        android:textColor="@color/RED1"
        android:textSize="16sp"/>

</android.support.v7.widget.CardView>


<android.support.v7.widget.CardView
    android:id="@+id/card_text"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_above="@+id/card_bot2"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:layout_below="@+id/card_image"
    android:layout_marginBottom="-8dp"
    android:layout_marginTop="-8dp"
    app:cardBackgroundColor="@color/BLACK1"
    app:cardCornerRadius="5dp"
    app:cardElevation="8dp"
    app:cardMaxElevation="0dp"
    app:cardPreventCornerOverlap="false"
    app:cardUseCompatPadding="true">

    <EditText
        android:id="@+id/storyTextView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/choiceButton1"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:background="@null"
        android:cursorVisible="false"
        android:focusable="false"
        android:focusableInTouchMode="false"
        android:fontFamily="serif-monospace"
        android:gravity="center"
        android:lineSpacingMultiplier="1.2"
        android:paddingBottom="15dp"
        android:paddingLeft="18dp"
        android:paddingRight="18dp"
        android:paddingTop="15dp"
        android:textColor="@color/GREY1"
        android:textSize="16sp"
        />

</android.support.v7.widget.CardView>

<android.support.v7.widget.CardView
    android:id="@+id/card_image"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:layout_alignParentTop="true"
    android:layout_marginBottom="-8dp"
    android:layout_marginTop="-8dp"
    app:cardBackgroundColor="@color/BLACK1"
    app:cardCornerRadius="5dp"
    app:cardElevation="8dp"
    app:cardMaxElevation="0dp"

    app:cardPreventCornerOverlap="false"
    app:cardUseCompatPadding="true">

    <ImageView
        android:id="@+id/StoryImageView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_alignParentTop="true"
        android:adjustViewBounds="true"
        android:scaleType="fitXY"
        android:src="@drawable/page15"/>
</android.support.v7.widget.CardView>

This is how it looks(click)

例如我试过这个:https://stackoverflow.com/a/30046813/7130746 - 它没有制作Ripple效果,只有当我点击某个地方时才会改变颜色,其中没有文字

我认为我犯了愚蠢的错误,但不知道在哪里,有人帮忙吗? :)谢谢!!

没人知道? :(

0 个答案:

没有答案