1

我试图在开关兼容上应用激进反应/涟漪效应,但我能从中得到的最多是一个短暂的效果。我在一行中有一个开关,一旦打开和关闭开关,我想在整个行中突出显示。目前唯一突出的是开关,它也没有涟漪效应,就像开关本身的暗淡亮点一样。一旦开关被翻转,是否可以在整个行中发出波浪/涟漪效应?这是我的代码:

<FrameLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/altercolor2"
         android:padding="@dimen/common_padding">

        <com.myapp.utils.FontTextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textColor="#ffffff"
            android:paddingTop="@dimen/common_top_padding"
            android:paddingLeft="0dp"
            android:paddingBottom="@dimen/common_bottom_padding"
            android:textSize="@dimen/title"
            foo:customFont="proxima-nova-regular.ttf"
            android:text="@string/display_image" />

        <android.support.v7.widget.SwitchCompat
            android:id="@+id/display_image_toggle_control"
            foo:theme="@style/MyMaterialTheme.Switch"
            android:background="?attr/selectableItemBackgroundBorderless"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="right|center_vertical"
            android:layout_marginLeft="@dimen/toggle_margin_leftright"
            android:layout_marginRight="2dp" />
    </FrameLayout>
4

1 回答 1

0

您可以添加自己的涟漪效果,创建一个drawable-v21文件夹并将以下可绘制对象作为您的背景,FrameLayout我想可以解决您的问题:

<?xml version="1.0" encoding="utf-8"?>

<ripple xmlns:android="http://schemas.android.com/apk/res/android"
    android:color="@color/gray_light">
    <item
        android:id="@android:id/mask"
        android:drawable="@color/gray" />
</ripple>

还添加:

android:clickable="true"
android:focusable="true"

一旦开关被翻转,是否可以在整个行中发出波浪/涟漪效应?

我认为您需要在您的视图中设置foreground和。background

于 2016-08-30T18:07:53.187 回答