package com.camnter.newlife.utils;

import android.app.Activity;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.view.View;
import android.widget.EditText;

/**
 * Description：ViewUtil
 * Created by：CaMnter
 * Time：2015-12-04 22:33
 */
public class ViewUtil {
    /**
     * Set view alpha
     * 设置透明度
     *
     * @param view  view
     * @param alpha alpha value
     */
    public static void setAlpha(View view, int alpha) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
            view.setAlpha(alpha / 255.0f);
        } else {
            Drawable drawable = view.getBackground();
            if (drawable != null) {
                drawable.setAlpha(alpha);
            }
        }
    }

    /**
     * 根据Android系统版本，调用版本API中的设置EditText背景的方法
     * According to the Android version, calls the Settings in the EditText background method of version API
     *
     * @param editText
     * @param drawable
     */
    public static void setEditTextBackgroundDrawable(EditText editText,Drawable drawable){
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            editText.setBackground(drawable);
        } else {
            editText.setBackgroundDrawable(drawable);
        }
    }

}

@@ -33,37 +33,8 @@
 s;%0A%0A
-import android.app.Activity;%0A
 impo
@@ -126,40 +126,8 @@
 iew;
-%0Aimport android.widget.EditText;
 %0A%0A/*
@@ -731,24 +731,20 @@
 %E6%9C%ACAPI%E4%B8%AD%E7%9A%84%E8%AE%BE%E7%BD%AE
-EditText
+View
 %E8%83%8C%E6%99%AF%E7%9A%84%E6%96%B9%E6%B3%95%0A  
@@ -808,24 +808,20 @@
  in the 
-EditText
+View
  backgro
@@ -867,24 +867,29 @@
  @param 
-editText
+view     view
 %0A     * 
@@ -903,16 +903,25 @@
 drawable
+ drawable
 %0A     */
@@ -947,24 +947,20 @@
 void set
-EditText
+View
 Backgrou
@@ -974,26 +974,19 @@
 ble(
-EditText editText,
+View view, 
 Draw
@@ -999,16 +999,17 @@
 rawable)
+ 
 %7B%0A      
@@ -1081,32 +1081,28 @@
             
-editText
+view
 .setBackgrou
@@ -1148,16 +1148,12 @@
     
-editText
+view
 .set

update ViewUtil