In Android development, the methods, classes, or interfaces that allow you to see each other are quite different.

Source: Internet
Author: User
Tags manual writing

In Android development, the methods, classes, or interfaces that allow you to see each other are quite different.

Source: liukun (@ TheFresher)

PS: In this article, I am familiar with Android development. What methods, classes, or interfaces do you think you may find different? The answer to this question is summarized at present. If new discoveries are found in the future, they can be supplemented at any time. Likes.

  • GetParent (). requestDisallowInterceptTouchEvent (true); deprive the parent view of the right to process touch events, who knows who to use.
  • ArgbEvaluator. evaluate (float fraction, Object startValue, Object endValue); used to generate a new color based on a starting color value, an ending color value, and an offset, the color gradient is similar to the sliding color gradient on the bottom bar in minutes.
  • The apis of the clipRect, clipPath, and clipRegion cut areas in the Canvas.
  • Bitmap. extractAlpha (); returns the alpha value of the new Bitmap and capture original image. Sometimes, when we need to dynamically modify the background image of an element and do not want to use multiple images, we can dynamically modify the color of a solid Bitmap by combining Canvas and Paint.
    • HandlerThread, instead of the repeated manual Writing of non-stop new threads.
    • IntentService, a Service that can die after it is finished and does not require us to Manage Sub-threads.
    • Palette, 5.0 can be added to extract a highlighted color class from Bitmap, combined with Bitmap. extractAlpha above, you know.
    • Executors. newSingleThreadExecutor (); this is java. I did not know it before. I spent a lot of time studying the task queue for single-threaded sequential execution ..
    • Android: animateLayoutChanges = "true". You can use setLayoutTransition () to add a View animation to LinearLayout.
    • ViewDragHelper: It is very tiring to process various events when you define a ViewGroup that can be dragged by a sub-View, huh? What the fuck !!
    • GradientDrawable, who previously took over the company's project, found that there was a shadow effect that was not bad. He thought it was a cut image, a look at the code, what ghost =!
    • AsyncQueryHandler: If you develop system tools, such as the contact text message auxiliary tool, you must deal with ContentProvider. If the data volume is not large, do whatever you want, if there is a large amount of data, it is necessary to understand this class. Note that this is an exception ..
    • ViewFlipper enables switching (loop) of multiple views, allows you to customize the animation effect, and allows you to specify an animation for a single switch.
    • Some people mentioned that some methods in custom View do not work when hardware acceleration is enabled. Many methods do not support hardware acceleration after api16, we usually close hardware acceleration through the configuration file. In fact, android also provides a way to disable hardware acceleration for a specific View and call View. setLayerType (View. LAYER_TYPE_SOFTWARE, null.
    • The Pair class in the android util package can be conveniently used to store a "group" of data. Note that it is not a key value.
    • PointF, a class in the graphics package. We often see that when processing Touch events, we define a downX and a downY to store a coordinate. If there are few coordinates, if you want to record more coordinates, the code won't look good. It is clear to use PointF (float x, float y); To describe a coordinate point.
    • StateListDrawable: the general method for defining Selector is xml files, but sometimes our image resources may be dynamically obtained from the server, such as the so-called skin of many apps. In this case, only StateListDrawable can be used.
      To complete the addState.
    • Android: descendantFocusability: When the CheckBox and other elements in the ListView item fail to respond to the item click event, in addition to setting the focusable for the corresponding element, it is simpler to add android to the item root layout: descendantFocusability = "blocksDescendants"
    • Android: duplicateParentState = "true", so that the sub-View follows the state of its Parent, such as pressed. A common use case is that a button is very small in some cases. When we want to expand the click area, we usually wrap it up with a layout and write the click event to the Parent, in this case, if you want the Selector corresponding to the clicked effect of the wrapped button to continue to take effect, duplicateParentState will be used in this case.
    • IncludeFontPadding = "false". By default, TextView has a certain number of padding values. Sometimes we do not need to leave the upper and lower parts white, and add it.
    • Messenger is usually asked about inter-process communication during the interview. Generally, everyone starts to endorse AIDL Bala .. One day I saw this on the blog of Hong Shen. Well, as he said, I can install it again.
    • TextView. setError (); used to verify user input.
    • ViewConfiguration. getScaledTouchSlop (); minimum distance to trigger a mobile event. When a custom View processes a touch event, it is necessary to determine whether the user actually has a movie. The system provides this method.
    • ValueAnimator. reverse (); smooth animation cancellation.
    • ViewStub. Sometimes, different la s need to be displayed in a region based on the actual situation. Generally, we use the setVisibility method to display and hide different la S. However, by default, all la s are loaded, viewStub can improve the performance.
    • OnTrimMemory, this method is rewritten in the Activity, callback will be performed when the memory is insufficient (multiple levels are supported), so that we can actively release resources and avoid OOM.
    • EditTxt. setImeOptions: When you use EditText to pop up a soft keyboard, you can modify the display content of the Enter key. (I hate using the Enter key for interaction, so I never knew about it before)
    • TextView. setCompoundDrawablePadding. The Code sets the drawable padding of TextView.
    • ImageSwitcher is a class used for image switching, similar to slides.
    • The direct use of HashMap in WeakHashMap sometimes brings the risk of memory overflow. When the user no longer has an object reference, WeakHashMap will be automatically removed from the object with the corresponding Key value.
    • QQ technology exchange group 290551701 http://cxy.liuzhihengseo.com/548.html

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.