The original intention of writing this example is to imitate the address book list, which achieves some effects and cannot be 100% identical. I think there are still some shortcomings (some memory waste ).
This is the first step in this phase. If the amount of code is large, no code will be pasted.
Source code:
Http://download.csdn.net/source/3245470
As follows:
1. implement classification by letter.
2. implement quick slide and modify the icon of the quick slide bar.
3. letter tips for fast sliding.
4. the shortcut box and its animation display/hide are implemented. The up arrow and down arrow show and position match selectively.
5. By the way, a custom dialog and complete email sending (master, CC, BCC, attachment, title, and body) are implemented ).
Some Implementation Details:
1. letter prompt box for quick sliding
The display component is textview and the instance index name is txtoverlay. Run windowmanager. addview (txtoverlay, layoutparams) and add it to windowmanager. When listview. onscrolllistener is set to listen to scroll, txtoverlay is set to view. Visible. When the scroll ends, the visibility is changed to view. Invisible.
To improve the user experience, you can run the show and hide commands in the letter prompt box when you drag it again in a short time, and set the hidden operations in the disapearthread thread instance through handler. postdelayed (disapearthread, 1500) is delayed for 1.5 seconds and then hidden by a letter prompt box.
2. Modify the quick scroll icon
The android API does not publicly modify the icon interface. In this example, the quick scrolling icon is modified by calling the Java reflection mechanism. For the replacement code, see changefastscrollerdrawable () in the mainact class ().
Supplement: Android optimizes the listview settings. For a list with less than four pages, fastscrollenabled is not displayed even if fastscrollenabled is set to true.
For more information, see <android_source>/frameworks/base/CORE/Java/Android/widget/fastscroller. Java: the constant min_pages and its correlation.
3. Obtain the absolute position of the "grui" imageview in the list on the screen.
The Code is as follows: anchor is the "teeth" imageview.
Int [] Location = new int [2]; <br/> anchor. getlocationonscreen (location); <br/> rect anchorrect = new rect (location [0], location [1], location [0] + anchor. getwidth (), <br/> location [1] + anchor. getheight ());
This step also paves the way for the automatic selection of the up arrow and down arrow.
4. Set a bounce animation for the linearlayout composed of shortcuts.
The animation definition file that sets linearlayout to slide from the right of the screen to the left is res/anim/anim_actionslayout.xml. The Code is as follows:
<? XML version = "1.0" encoding = "UTF-8"?> <Br/> <! -- This file specifies the animation of actionslayout. --> <Br/> <! -- Translate defines a movement in the vertical or horizontal direction or a mixture of the two. --> <Br/> <! -- Formxdelta: assign a value to a floating point or percentage. 'P' after the percent sign indicates the corresponding position relative to the parent control. If there is only a percent sign, it indicates the position relative to the control. --> <Br/> <! -- View the specific values of @ Android: integer/config_longanimtime in <sdk_path>/platforms/<Android-level>/data/RES/values/config. XML --> <br/> <translate xmlns: Android = "http://schemas.android.com/apk/res/android" <br/> Android: fromxdelta = "100% P" <br/> Android: toxdelta = "0" <br/> Android: Duration = "@ Android: integer/config_longanimtime" <br/> </translate>
You have to set the interpolator for the animation effect to be rebounded. You have to find a proper function to correct the animation speed. The interpolation code used in this example is as follows:
Package lab. sodino. list_quickaction; <br/> Import android. util. log; <br/> Import android. view. animation. interpolator; <br/>/** <br/> * @ author sodino Email: sodinoopen@hotmail.com <br/> * @ version time: 08:02:01 <br/> */<br/> public class custominterpolator implements interpolator {<br/>/** <br/> * @ Param input <br/> * value between 0 and 1.0 indicating our current point in the <br/> * Nimation where 0 represents the start and 1.0 represents the <br/> * end <br/> * @ return returns the interpolation value. this value can be more than 1.0 <br/> * For interpolators which overshoot their targets, or less than 0 <br/> * For interpolators that undershoot their targets. <br/> */<br/> public float getinterpolation (float input) {<br/> log. D ("android_lab", "input =" + input); <br/> // set the animation Acceleration value. In this example, the result is that actionslayout exceeded the target rotation zone and then rebounded. <Br/> // interpolation formula: 1.2-(x * 1.55f)-1.1) ^ 2 <br/> // draw a function diagram to observe the detailed process of rebounding from the target area during animation execution. <Br/> // X: 0 <= V <= 1.0 <br/> // (x * 1.55f ): 0 <= V <= 1.55 <br/> // (x * 1.55f)-1.1 ): -1.1 <= V <= 0.45 <br/> // (x * 1.55f)-1.1) ^ 2: 0 <= V <= 1.21 <br/> // 1.2-(x * 1.55f)-1.1) ^ 2: -0.1 <= V <= 1.2 <br/> final float inner = (input * 1.55f)-1.1f; <br/> // if the return value is constant 1, it is equivalent to no animation effect. <Br/> return 1.2f-inner * inner; <br/>}< br/>}
At last, the author summarized the achievements of his predecessors and then used them. The following are references:
1. apidemo
2. http://marshal.easymorse.com/archives/3929
3. http://www.londatiga.net/it/
This article is owned by sodino, A csdn blog blogger.
Reprinted please indicate the source: http://blog.csdn.net/sodino/archive/2010/12/15/6077017.aspx