转自:http://blog.danlew.net/2014/05/12/android-tips-round-up-part-4/

Here's the fourth round-up of Android tips I've been posting.

More:Part 1|Part 2|Part 3| Part 4 |Part 5

Activity.isChangingConfigurations()- Often times you don't need to do quite as much saving of state if all that's happening is the configuration is changing.

SearchRecentSuggestionsProvider- A quick and easy way to create a recents suggestion provider.

ViewTreeObserver- This is an amazing utility; it can be grabbed from any View and used to monitor the state of the View hierarchy. My most often use for it is to determine when Views have been measured (usually for animation purposes).

org.gradle.daemon=true- Helps reduce the startup time of of Gradle builds. Only really applies to command-line builds as Android Studio already tries to use the daemon.

DatabaseUtils- A variety of useful tools for database operations.

android:weightSum (LinearLayout)- Want to use layout weights, but don't want them to fill the entire LinearLayout? That's what weightSum can do by defining the total weight.

android:duplicateParentState (View)- Makes the child duplicate the state of the parent - for example, if you've got a ViewGroup that is clickable, then you can use this to make its children change state when it is clicked.

android:clipChildren (ViewGroup)- If disabled, this lets the children of a ViewGroup draw outside their parent's bounds. Great for animations.

android:fillViewport (ScrollView)- Best explained inthis post, this helps solve a problem with ScrollViews that may not always have enough content to actually fill the height of the screen.

android:tileMode (BitmapDrawable)- Lets you create repeated patterns with images.

android:enterFadeDuration/android:exitFadeDuration (Drawables)- For Drawables that have multiple states, this lets you define a fade before/after the drawable shows.

android:scaleType (ImageView)- Defines how to scale/crop a drawable within an ImageView. "centerCrop" and "centerInside" are regular settings for me.

<merge>- Lets you include a layout in another without creating a duplicate ViewGroup (more info). Also good for custom ViewGroups; you can inflate a layout with<merge>inside the constructor to define its children automatically.

AtomicFile- Manipulates a file atomically by using a backup file. I've written this myself before, it's good to have an official (and better-written) version of it.

更多相关文章

  1. 代码中设置drawableleft
  2. android 3.0 隐藏 系统标题栏
  3. Android开发中activity切换动画的实现
  4. Android(安卓)学习 笔记_05. 文件下载
  5. Android中直播视频技术探究之—摄像头Camera视频源数据采集解析
  6. 技术博客汇总
  7. android 2.3 wifi (一)
  8. AndRoid Notification的清空和修改
  9. Android中的Chronometer

随机推荐

  1. Android TextView追加文字
  2. Android(java.lang.NullPointerException
  3. Android设备抓包命令
  4. android下保存用户账号密码和读取账号密
  5. Android:使用SpannableString实现图片替
  6. android 画图 Matrix
  7. Use Android NDK r7 to compile FFmpeg0.
  8. androidRadioGroup和RadioB…
  9. android asm.jar
  10. Android APP终极瘦身指南