yechaoa
【整理篇】Android 开发小技巧
关注作者
前往小程序,Get
更优
阅读体验!
立即前往
腾讯云
开发者社区
文档
建议反馈
控制台
登录/注册
首页
学习
活动
专区
圈层
工具
文章/答案/技术大牛
搜索
搜索
关闭
发布
首页
学习
活动
专区
圈层
工具
返回腾讯云官网
yechaoa
首页
学习
活动
专区
圈层
工具
返回腾讯云官网
社区首页
>
专栏
>
【整理篇】Android 开发小技巧
【整理篇】Android 开发小技巧
yechaoa
关注
发布于 2022-06-10 12:49:42
发布于 2022-06-10 12:49:42
656
0
举报
文章被收录于专栏:
移动开发专栏
移动开发专栏
/storage/emulated/0/…
手机内部存储路径
mEditText.setKeyListener(null);
EditText设置不可编辑,比focusable、enable更粗暴
android:foreground="?android:attr/selectableItemBackground"
item的水波纹效果,在item的View加上这一属性, 5.0+才行
includeFontPadding=“false”
去除TextView上下的padding
viewpager的item点击事件
viewpager底层拦截了点击事件,所以点击事件写在adapter里面
android:imeOptions=“actionDone”
EditText修改软键盘的回车键
android:contentDescription="@null"
ImageView去除缺少描述的警告
tools:text=“预览”
使用tools属性工具预览布局
android:largeHeap=“true”
给App增加更大的内存,AndroidManifest的Application 节点
TextUtils.isEmpty()
自带判空util
TextView.setError()
验证用户输入
Context.getCacheDir()
获取缓存数据文件夹的路径
DateUtils.formatDateTime()
用来进行区域格式化工作,输出格式化和本地化的时间或者日期
Linkify.addLinks()
在Text上添加链接。很实用
Fragment.setArguments
在创建 Fragment 之前设置参数
LocalBroadcastManager
这个会比全局的 broadcast 更加安全,简单,快速
PhoneNumberUtils.formatNumber ()
顾名思义,这是对数字进行格式化操作的时候用的
Application.registerActivityLifecycleCallbacks
管理Activity的生命周期
Activity.recreate ()
强制让 Activity 重建
SparseArray
Map的高效优化版本
isShown()
判断view是否显示
performClick()
模拟点击
TextWatcher
监听EditText输入
android:screenOrientation=“portrait”
activity 竖屏
android:windowSoftInputMode=“adjustPan|stateVisible”
适配带有输入框的页面
android:weightSum=“3”
设置LinearLayout中的权重总数
android:fillViewport=“true”
ScrollView设置全屏
SystemClock.sleep()
延时操作
CountDownTimer
倒计时
view.post()、View.postDelay()
更新UI,延时操作
DateUtils.getRelativeTimeSpanString(long startTime)
返回 “几天前”/“xx days ago” 格式的字符串,自带翻译
mWebView.canGoBack()
webview判断是否可返回
DiffUtil
处理Recyclerview数据流
setBackground(ContextCompat.getDrawable(this, R.drawable.icon))
代替setBackgroundDrawable()
ContextCompat.getDrawable(context, R.drawable.your_drawable)
代替getDrawable(int)
ContextCompat.getColor(context, R.color.color_name)
代替getColor(int)
app:tabTextAppearance="@android:style/TextAppearance.Widget.TabWidget"
解决TabLayout默认英文大写
android:textAllCaps=“false”
解决Button默认英文大写
android:includeFontPadding=“false”
去掉TextView内部padding
快捷键
提高开发效率
live template动态模板
提高开发效率
Android快速开发整理(库、插件、常用网站)
提高开发效率
Github Android-Develop-Tips
欢迎补充
本文参与
腾讯云自媒体同步曝光计划
,分享自作者个人站点/博客。
原始发表:2018-04-27,如有侵权请联系
cloudcommunity@tencent.com
删除
前往查看
android
textview
webview
网站
本文分享自
作者个人站点/博客
前往查看
如有侵权,请联系
cloudcommunity@tencent.com
删除。
本文参与
腾讯云自媒体同步曝光计划
,欢迎热爱写作的你一起参与!
android
textview
webview
网站
评论
登录
后参与评论
0 条评论
热度
最新
推荐阅读
目录
/storage/emulated/0/…
mEditText.setKeyListener(null);
android:foreground="?android:attr/selectableItemBackground"
includeFontPadding=“false”
viewpager的item点击事件
android:imeOptions=“actionDone”
android:contentDescription="@null"
tools:text=“预览”
android:largeHeap=“true”
TextUtils.isEmpty()
TextView.setError()
Context.getCacheDir()
DateUtils.formatDateTime()
Linkify.addLinks()
Fragment.setArguments
LocalBroadcastManager
PhoneNumberUtils.formatNumber ()
Application.registerActivityLifecycleCallbacks
Activity.recreate ()
SparseArray
isShown()
performClick()
TextWatcher
android:screenOrientation=“portrait”
android:windowSoftInputMode=“adjustPan|stateVisible”
android:weightSum=“3”
android:fillViewport=“true”
SystemClock.sleep()
CountDownTimer
view.post()、View.postDelay()
DateUtils.getRelativeTimeSpanString(long startTime)
mWebView.canGoBack()
DiffUtil
setBackground(ContextCompat.getDrawable(this, R.drawable.icon))
ContextCompat.getDrawable(context, R.drawable.your_drawable)
ContextCompat.getColor(context, R.color.color_name)
app:tabTextAppearance="@android:style/TextAppearance.Widget.TabWidget"
android:textAllCaps=“false”
android:includeFontPadding=“false”
快捷键
live template动态模板
Android快速开发整理(库、插件、常用网站)
Github Android-Develop-Tips
领券
问题归档
专栏文章
快讯文章归档
关键词归档
开发者手册归档
开发者手册 Section 归档
0
0
0
推荐