Some of the neglected but useful classes and methods in Android development

Source: Internet
Author: User
Tags intl

Mediametadataretriever

As the name implies, is the class used to get some information about the media file. Includes the title of a song, author, album cover and Name, duration, bitrate, etc. If it is a video, you can get the length and width of the video, preview the image.

Http://developer.android.com/intl/zh-cn/reference/android/media/MediaMetadataRetriever.html

Touchdelegate

Used to change the touch area of a view. Scenario: For example, if you include a CheckBox component in a Recyclerview Itemview, and then you want to implement a click Itemview, you can also trigger a checkbox to use this class.

Http://developer.android.com/intl/zh-cn/training/gestures/viewgroup.html#delegate

Argbevaluator

for calculating the interpolation between different color values, mates ValueAnimator.ofObject or ViewPager.PageTransformer use, you can achieve a smooth transition between different colors.

Http://developer.android.com/intl/zh-cn/reference/android/animation/ArgbEvaluator.html

Palette

The color used to extract a picture.

Http://developer.android.com/intl/zh-cn/reference/android/support/v7/graphics/Palette.html

Viewdraghelper

Custom ViewGroup shoes Should know this thing, to handle the touch event artifact, mom no longer have to worry about my custom control.

Http://developer.android.com/intl/zh-cn/reference/android/support/v4/widget/ViewDragHelper.html

Http://www.cnblogs.com/lqstayreal/p/4500219.html

Pagetransformer

Used to define the animation effect when the Viewpager page is toggled (fade in, zoom out of the god horse ...) There are examples of the official, see it directly.

Http://developer.android.com/intl/zh-cn/training/animation/screen-slide.html

Viewflipper

A component that can implement a simple carousel effect.

Http://developer.android.com/intl/zh-cn/reference/android/widget/ViewFlipper.html

Localbroadcastmanager

A broadcast tool class that is used within the app for better efficiency and security.

Http://developer.android.com/intl/zh-cn/reference/android/support/v4/content/LocalBroadcastManager.html

Messenger

A tool class for interprocess communication. The interior is also implemented by AIDL, but it is super convenient to use.

Http://developer.android.com/intl/zh-cn/reference/android/os/Messenger.html

http://blog.csdn.net/lmj623565791/article/details/47017485

Formatter.formatfilesize

The tool class is automatically converted to KB, MB, GB, depending on the file size. Think of the past is the calculation of their own ...

Http://developer.android.com/intl/zh-cn/reference/android/text/format/Formatter.html

Activity.recreate

Re-create the activity. What's the use of it? You can refresh the current activity immediately after the program has changed the theme, without the obvious animation of restarting the activity.

Http://developer.android.com/intl/zh-cn/reference/android/app/Activity.html#recreate%28%29

View.getcontext

As the name implies, you don't have to explain it ... Before writing Recyclerview's adapter, in order to use the layoutinflater, often foolishly in the constructor to pass in an external context .... Is it only I don't know (laughter cry face)

Http://developer.android.com/intl/zh-cn/reference/android/view/View.html#getContext ()

View.post

It is convenient to modify the interface in a non-UI thread, similar to the role of handler. And since Post's runnable is guaranteed to be called when the view is drawn, it can also be used to get the width of the view.

Http://developer.android.com/intl/zh-cn/reference/android/view/View.html#post (java.lang.Runnable)

Activity.runonuithread

View.postSimilarly, it is convenient to modify the interface in a non-UI thread.

Http://developer.android.com/intl/zh-cn/reference/android/app/Activity.html#runOnUiThread (java.lang.Runnable)

Fragment.setuservisiblehint

Fragment can override this method, and then perform some logic based on the Boolean value of the parameter (true to indicate that the current fragment is visible to the user).

Http://developer.android.com/intl/zh-cn/reference/android/support/v4/app/Fragment.html#setUserVisibleHint ( Boolean

Android:animatelayoutchanges

This is a very cool property. After the parent layout is added android:animateLayoutChanges="true" , if the layout method is triggered (for example, its sub-view is set to gone), the system will automatically help you add animation effects when the layout changes!!

Http://developer.android.com/intl/zh-cn/training/animation/layout.html

Android:cliptopadding

Sets whether the parent view allows its child view to be drawn in its padding (this refers to the padding of the parent view). Isn't it a little bit around? Let's take a practical scenario: if there is a ListView, we want to be in the initial position, the first item is 10DP away from the top, and can be added to the ListView layout android:clipToPadding="false" android:paddingTop="10dp" . Isn't it convenient?

Http://developer.android.com/intl/zh-cn/reference/android/view/ViewGroup.html#attr_android:clipToPadding

Some of the neglected but useful classes and methods in Android development

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.