MD风格
来源:互联网 发布:软件测试外包 编辑:程序博客网 时间:2024/05/16 01:22
1 安卓沉浸式状态栏(如果不成功请看2)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);}
2 首先下载systemBartint.jar包,
<resources> <!-- Base application theme. --> <style name="AppTheme" parent="android:Theme.Holo.Light.NoActionBar.TranslucentDecor"> <!-- Customize your theme here. --> <item name="android:windowContentOverlay">@null</item> <item name="android:windowNoTitle">true</item> <item name="android:windowSoftInputMode">stateAlwaysHidden|adjustPan</item> <item name="android:fitsSystemWindows">true</item> <item name="android:windowTranslucentStatus">true</item> <item name="android:windowTranslucentNavigation">false</item> <item name="android:screenOrientation">portrait</item> </style></resources>private void initState() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { SystemBarTintManager tintManager = new SystemBarTintManager(this); tintManager.setStatusBarTintEnabled(true); tintManager.setNavigationBarTintEnabled(false); tintManager.setStatusBarTintResource(R.color.head_bg_color); }}然后再相应地方调用。。
只有安卓4.4以上支持。。
2 控件水波纹效果
dependencies { compile 'com.github.traex.rippleeffect:library:1.3'}
<com.andexert.library.RippleView android:layout_width="wrap_content" android:layout_height="wrap_content" app:rv_alpha="90" app:rv_centered="false" app:rv_color="#00ffff" app:rv_framerate="10" app:rv_rippleDuration="400" app:rv_ripplePadding="1dp" app:rv_type="simpleRipple" app:rv_zoom="false" app:rv_zoomDuration="150" app:rv_zoomScale="1.03" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#ffffff" android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:text="Hello World!" /></com.andexert.library.RippleView>
3 TextInputLayout控件的使用<android.support.design.widget.TextInputLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/usernameWrapper" app:hintTextAppearance="@style/CustomTextInputLayoutAppearance"
<style name="CustomTextInputLayoutAppearance"> <item name="android:textSize">18sp</item> <item name="android:textColor">#03f494</item></style>
android:layout_centerVertical="true" android:layout_alignParentLeft="true" android:layout_alignParentStart="true"> <EditText android:id="@+id/password" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="密码" android:singleLine="true" android:ellipsize="start" android:textColor="#00ff00" android:textColorHint="#009900" android:inputType="textPassword" android:maxLength="15" android:imeOptions="actionDone" android:layout_below="@+id/editText" android:layout_alignParentLeft="true" android:layout_alignParentStart="true" android:layout_marginTop="62dp" /></android.support.design.widget.TextInputLayout>
passwordWrapper.setHint("密码"); passET.setOnFocusChangeListener(new View.OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { if (!hasFocus) { checkPass(); } } });} private boolean checkPass() { String pass = passET.getText().toString(); if (pass.length() < 6) { passwordWrapper.setErrorEnabled(true); passwordWrapper.setError("密码少于6位数"); return false; } passwordWrapper.setErrorEnabled(false); return true;}
修改colorAccent
属性便可以指定TextInputLayout
的标签字体颜色以及EditText
的下划线颜色。<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> <item name="colorAccent">#3498db</item></style>
对用户的输入(即mTextInputLayout.getEditText().getText().toString()
)在后台进行验证,如果检查到用户输入不合法,可以通过setError()
显示输入错误提示,以及setErrorEnabled(fasle)
清除错误提示。
验证邮箱是否正确 private static final String EMAIL_PATTERN = "^[a-zA-Z0-9#_~!$&‘()*+,;=:.\"(),:;<>@\\[\\]\\\\]+@[a-zA-Z0-9-]+(\\.[a-zA-Z0-9-]+)*$";private Pattern pattern = Pattern.compile(EMAIL_PATTERN);private Matcher matcher;public boolean validateEmail(String email) { matcher = pattern.matcher(email); return matcher.matches();}
0 0
- MD风格
- Android-MD风格设置
- MD的配色风格
- Android MD风格颜色汇总
- 自己设计MD风格侧滑栏
- MD风格(ToolBar+Theme)
- Android 走向MD的配色风格
- MD风格之丰富多变Toolbar
- Android MD风格相关控件小结
- Android——MD风格转场动画
- Android:使用android-support-design实现MD风格对话框
- 如何实现一个标准的MD风格页面
- MD风格的progressbar实现,可以在5.1以下使用
- 基于MVP-RxJava-Retrofit的MD风格阅读软件
- 卡片式布局 MD风格设计 卡片式背景
- Rxjava+Retrofit+MVP MD风格 的阅读类APP-HiReader
- Flutter学习之旅(二)----MD风格和点击事件
- MD风格Mvp—RxJava2应用,MVP初体验
- 图片压缩
- 多线程三-------------线程中常用的函数
- webdriver定位元素技巧
- 阶乘的精确值(大数)
- 互盾苹果恢复大师怎么恢复微信删除的记录
- MD风格
- jeecg 与 jeecg-p3有什么区别?
- C# 代码中调用ActiveX控件更新接口造成编译错误的问题
- 跨浏览器插件框架FireBreath安装与使用之一——Windows下的插件
- CSDN-markdown编辑器 模板
- 建议66:正确捕获多线程中的异常
- CNN网络分解--Factorized Convolutional Neural Networks
- Angular js指令收录(五)
- 纹理矩阵堆栈/深度纹理和阴影的绘制