26
2017
09

Android ripple 波纹超出边界和波纹有边界一起出现

最近调按键效果时出现了当给ImageView设置了自定义颜色波纹超出边界时在抬起时波纹有边界也出现;在此做下记录:

<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android" android:color="#33000000" />
    <ImageView
        android:id="@+id/clean_image"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentEnd="true"
        android:paddingStart="@dimen/search_view_bar_icon_delete_padding"
        android:paddingEnd="@dimen/search_view_bar_icon_delete_padding"
        android:layout_marginStart="@dimen/search_view_bar_icon_delete_margin"
        android:layout_marginEnd="@dimen/search_view_bar_icon_delete_margin"
        ***android:background="@drawable/ripple_background"***
        android:layout_marginTop="@dimen/search_view_bar_delete_icon_margin_top"
        android:src="@drawable/search_bar_delete_icon"
        android:visibility="gone" />

因为这个控件是要做点击后动画隐藏 而当隐藏时波纹有边界就出现了;最后通过延迟消失时间来解决

mCleanImage.animate().alpha(0f).***setStartDelay(280)***/*.scaleX(0f).scaleY(0f)*/.setDuration(150).setInterpolator(new AccelerateInterpolator()).withEndAction(new Runnable() {
            @Override
            public void run() {
                mCleanImage.setVisibility(View.GONE);
            }
        }).start();
上一篇:AR项目实践二:ar直尺 下一篇:iOS 关于UILabel文本的自适应