Android Tips Round-Up, Part 4

转自: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 in this 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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值