package com.qimai.android.tools

import android.graphics.Color
import android.graphics.drawable.GradientDrawable
import android.view.HapticFeedbackConstants
import android.view.View

/**
 * 设置背景
 */
fun View.setRoundRectBg(color: Int = Color.WHITE, cornerRadius: Float = 15f.dp) {
    background = GradientDrawable().apply {
        setColor(color)
        setCornerRadius(cornerRadius)
    }
    /**
     * 点击view的时候震动
     * @receiver View
     */
     fun View.shock() {
        this.performHapticFeedback(
            HapticFeedbackConstants.LONG_PRESS,
            HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING)
    }
}

