不会在棒棒糖上产生涟漪效应的switchcompat工作?

时间:2016-09-15 14:04:03

标签: android material-design androiddesignsupport rippledrawable switchcompat

我一直在尝试使用支持开关compat的开关来连接棒棒糖。它在棉花糖上工作正常并且显示出预期的涟漪效果,但在棒棒糖版本上它没有波纹。是不支持还是我做错了什么? 这是我的代码:

<FrameLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@color/green"
            android:padding="0dp"
            >

            <com.my.FontTextView
                android:layout_gravity="center_vertical"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                foo:customFont="proxima-nova-regular.ttf"
                android:textColor="#cccccc"
                android:paddingTop="@dimen/autosign_download_topbottompadding"
                android:paddingLeft="@dimen/common_left_padding"
                android:paddingBottom="@dimen/autosign_download_topbottompadding"
                android:textSize="25sp"
                android:text="sign here" />

            <android.support.v7.widget.SwitchCompat
                android:id="@+id/signin_toggle_control"
                foo:theme="@style/MyMaterialTheme.Switch"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="@drawable/ripple_effect"
                android:layout_gravity="right|center_vertical"
                android:layout_marginLeft="@dimen/toggle_margin_leftright"
                android:layout_marginRight="2dp" />

        </FrameLayout>

ripple_effect.xml

<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:color="@color/gray"
    android:radius="600dp"
    tools:targetApi="LOLLIPOP">
    <item android:id="@android:id/mask"
        android:drawable="@color/gray"
        android:clickable="true"
        android:focusable="true">
        <shape
            android:shape="oval">
            <solid android:color="?android:colorAccent" />
        </shape>
    </item>
</ripple>

切换风格:

 <style name="MyMaterialTheme.Switch" parent="Widget.AppCompat.Button.Colored">
        <!-- colorAccent is used as the default value for colorControlActivated,
                 which is used to tint widgets -->
        <item name="colorAccent">@color/thumboff</item>
        <!-- Active thumb color & Active track color(30% transparency) -->
        <item name="colorControlActivated">@color/thumbon</item>
        <!-- Inactive thumb color -->
        <item name="colorSwitchThumbNormal">@color/thumboff</item>
        <!-- Inactive track color(30% transparency) -->
        <item name="android:colorForeground">@color/trackoff</item>
        <!-- You can also set colorControlNormal, colorControlActivated
             colorControlHighlight, and colorSwitchThumbNormal. -->

    </style>

0 个答案:

没有答案