Преглед изворни кода

完善了文本编辑框的属性设置方法

不会爬树的猴 пре 2 година
родитељ
комит
1c7e4b898d
1 измењених фајлова са 49 додато и 0 уклоњено
  1. 49 0
      app/src/main/java/com/cr/widget/CrEditTextWidget.kt

+ 49 - 0
app/src/main/java/com/cr/widget/CrEditTextWidget.kt

@@ -124,6 +124,55 @@ class CrEditTextWidget @JvmOverloads constructor(
     }
 
     /**
+     * 设置是否为密码框
+     * @param isPassword Boolean
+     */
+    fun setIsPassword(isPassword:Boolean){
+        if(isPassword){
+            txtContent?.inputType = InputType.TYPE_TEXT_VARIATION_PASSWORD or InputType.TYPE_CLASS_TEXT
+        }else{
+            txtContent?.inputType = InputType.TYPE_CLASS_TEXT
+        }
+    }
+
+    /**
+     * 设置文字颜色
+     * @param color Int 颜色
+     */
+    fun setContentColor(color:Int){
+        txtContent?.setTextColor(color)
+    }
+
+    /**
+     * 设置提示文字颜色
+     * @param color Int 颜色
+     */
+    fun setContentHintColor(color:Int){
+        txtContent?.setHintTextColor(color)
+    }
+
+    /**
+     * 设置字体图标
+     * @param icoName String 图标名称
+     */
+    fun setFontIcon(icoName:String){
+        leftICO?.visibility = VISIBLE
+        imageView?.visibility = GONE
+        FontManager.setTextView(context!!,leftICO!!,icoName);
+    }
+
+    /**
+     * 设置图片图标
+     * @param drawable Drawable 图标资源
+     */
+    fun setImageIcon(drawable: Drawable){
+        leftICO?.visibility = GONE
+        imageView?.visibility = VISIBLE
+        imageView?.setImageDrawable(drawable)
+    }
+
+
+    /**
      * 视图点击事件
      * @param view View
      */