android常用功能
来源:互联网 发布:去眼下皱纹手术知乎 编辑:程序博客网 时间:2024/06/07 18:33
1.editText显示隐藏密码设置:
if (!flagPasswordSee) { Typeface font = Typeface.createFromAsset(getAssets(), "icomoon.ttf"); mTvSettingPasswordSee.setTypeface(font); mTvSettingPasswordSee.setText("\ue656"); mTvSettingPasswordSee.setTextColor(getResources().getColor(R.color.green_pressed)); TransformationMethod method = HideReturnsTransformationMethod.getInstance(); mEdtPassword.setTransformationMethod(method); /*Selection.setSelection(mEdtPassword.getText(), mEdtPassword.getText().length());*/ mEdtPassword.setSelection(mEdtPassword.getText().length()); flagPasswordSee = true; } else { Typeface font = Typeface.createFromAsset(getAssets(), "icomoon.ttf"); mTvSettingPasswordSee.setTypeface(font); mTvSettingPasswordSee.setText("\ue657"); mTvSettingPasswordSee.setTextColor(getResources().getColor(R.color.font_results_details_time_color)); TransformationMethod method = PasswordTransformationMethod.getInstance(); mEdtPassword.setTransformationMethod(method);// Selection.setSelection(mEdtPassword.getText(), mEdtPassword.getText().length()); mEdtPassword.setSelection(mEdtPassword.getText().length()); flagPasswordSee = false; }
2.html标记替换
/*** * @param textView * @param text */ public void setPromptText(TextView textView, String text) { if (textView == null || text == null) return; try { Pattern pattern = Pattern.compile("<em class=\"c-f60\">"); Matcher matcher = pattern.matcher(text); StringBuffer sbr = new StringBuffer(); while (matcher.find()) { matcher.appendReplacement(sbr, "<font color = '#FFA74D'>"); } matcher.appendTail(sbr); Pattern pattern1 = Pattern.compile("</em>"); Matcher matcher1 = pattern1.matcher(sbr.toString()); StringBuffer sbr1 = new StringBuffer(); if (matcher1.find()) { matcher1.appendReplacement(sbr1, "</font>"); } matcher1.appendTail(sbr1); textView.setText(Html.fromHtml(sbr1.toString())); } catch (Exception e) { textView.setText(text); return; } }
3.设置状态栏的颜色(沉浸式)
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setStatusBarColor(R.drawable.bg_header); } /** * 在API 19 的机器上设置状态栏的颜色 * * @param color 要设置的颜色 */ public void setStatusBarColor(int drawable) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { SystemBarTintManager tintManager = new SystemBarTintManager(this); tintManager.setStatusBarTintEnabled(true); tintManager.setStatusBarTintResource(drawable); } }
1 0
- Android常用功能实例
- Android常用功能实例
- Android常用功能代码
- Android常用功能
- Android 常用的功能
- Android常用功能汇总
- Android常用小功能
- android textView常用功能
- android 常用的功能
- Android常用功能代码
- android 常用的功能
- android常用功能
- Android开发常用功能
- android编程下常用功能
- android 常用调用系统功能
- Android Studio 常用功能介绍
- Android Studio常用功能配置
- Android Studio 常用功能介绍
- 欢迎使用CSDN-markdown编辑器
- OpenCV ROI区域图像叠加
- Scala学习笔记(四)
- python基础知识-GUI编程-TK-StringVar
- *c[];**cp[]和*cpp题目详解
- android常用功能
- iOS 共享文件的方法,应用间传文档
- 线性代数Lec02: 矩阵消元
- 9.10考试
- 自己写一个可以通过命令安装的cordova插件
- struts报错严重: Dispatcher initialization failed Unable to load configuration.
- uva1639 Candy
- Android中AIDL跨进程访问机制
- 通过经典题目来理解多种闭包实现方式