使用子级组件在Button中构建波纹效果

时间:2018-09-17 15:08:27

标签: android rippledrawable

我正在尝试从下面的图像在Android中构建Button。该按钮当前被实现为Button,其中ImageView内的ContraintLayout可以正常工作。

Button with child element

我现在需要添加一个传递到子ImageView的波纹效果。使用当前代码,每当我按下Button时,涟漪效应都会使 + ImageView消失并重新出现。我想要的是,当涟漪效应达到 + ImageView时,它会进入元素并在那里传播。当前代码如下:

<android.support.constraint.ConstraintLayout
    android:id="@+id/button_attach_camera"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/shape_card_header"
    android:backgroundTint="@color/detailsCardBackground"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/finish_input_body_visit_attachments_header_card"
    app:layout_constraintBottom_toTopOf="@+id/recycler_attachments">

    <android.support.v7.widget.AppCompatButton
        android:id="@+id/add_image_from_album"
        android:layout_width="100dp"
        android:layout_height="74dp"
        android:layout_marginStart="40dp"
        android:layout_marginEnd="36dp"
        android:layout_marginTop="8dp"
        android:background="@drawable/shape_status_card"
        android:drawableTop="@drawable/ic_gallery"
        android:fontFamily="@font/rubik"
        android:foreground="?android:attr/selectableItemBackgroundBorderless"
        android:paddingBottom="12dp"
        android:paddingEnd="12dp"
        android:paddingStart="12dp"
        android:paddingTop="12dp"
        android:text="@string/visit_finish_album_button"
        android:textAppearance="@style/TextAppearance.AppCompat"
        app:layout_constraintHorizontal_bias="0.0"
        app:layout_constraintEnd_toEndOf="parent" />


    <android.support.v7.widget.AppCompatImageView
        android:id="@+id/add_from_album_button"
        android:layout_width="24dp"
        android:layout_height="24dp"
        android:layout_marginStart="0dp"
        android:layout_marginTop="48dp"
        android:background="@drawable/shape_rounded_button_no_background"
        android:clickable="true"
        android:focusable="true"
        android:elevation="2dp"
        android:src="@drawable/ic_add_circle"
        app:layout_constraintStart_toStartOf="@+id/add_image_from_album"
        app:layout_constraintTop_toTopOf="@+id/add_image_from_album" />

</android.support.constraint.ConstraintLayout>

0 个答案:

没有答案