/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默認英文大寫
快捷鍵
- 提高開發效率
live template動態模板
- 提高開發效率
Android快速開發整理(庫、插件、常用網站)
- 提高開發效率
Github Android-Develop-Tips
歡迎補充